I need to add some code to the EndInit method of a PictureBox control, but unfortunately it's private and, from what I can gather, I can't shadow it and call ba开发者_JAVA技巧se - at least not in VB.NET.
What I can do is to add a dummy property to my picture box class. The type of the dummy property is simply a class that just implements ISupportInitialize
. However, that doesn't work, I need the dummy class to inherit from Control.
Is that the minimum requirement?
As you suspected, you need to make a proeprty that holds a dummy class implementing ISupportInitialize
.
Then, expose the property like this:
[EditorBrowsable(EditorBrowsableState.Never)] //Hide from IntelliSense (outside your solution)
[Browsable(false)] //Hide from Properties window
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public MyDummyClass Initializer { get; private set; }
Specifying DesignerSerializationVisibility.Content
will cause the designer to set the proeprties of the object instead of the object itself, and will also cause it to call BeginInit
/ EndInit
.
Obviously, you should instantiate the class in your constructor.
精彩评论