
Set Nothing to user-defined Image property through Properties Window
The easiest way is to simply create a subroutine (doesn't have to be
public) named "Reset<propertyname>" that sets your property value back to
Nothing. For instance:
Private m_MyImage As Image
Public Property MyImage() As Image
Get
Me.BackgroundImage
End Get
Set(ByVal Value As Image)
Me.BackgroundImage = Value
End Set
End Property
Private Sub ResetMyImage()
Me.BackgroundImage = Nothing
End Sub
If you add this and recompile your control, then go back to the property
browser. Find your property name ("MyImage" in the example above), and
right-click on the left-hand column, over the name of the function. You
should see a context menu with two options: "Reset" and "Description".
Click "Reset" (which originally would have been disabled - it should be
enabled now that you added your ResetMyImage function), and the MyImage
property will get reset back to Nothing (or whatever your ResetMyImage
function causes to happen will happen).
For more information, take a look at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpre...
frlrfsystemcomponentmodelpropertydescriptorclassresetvaluetopic.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgu...
l/cpconenhancingdesign-timesupport.asp
--
Stephen Weatherford, VB .NET Team
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| Content-Class: urn:content-classes:message
| Subject: Set Nothing to user-defined Image property through Properties
Window
| Date: Wed, 19 Mar 2003 02:47:49 -0800
| Lines: 7
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Thread-Index: AcLuBPxLRtZXQ4aiS1C4nFg8voeJaQ==
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Newsgroups: microsoft.public.dotnet.languages.vb
| Path: cpmsftngxa08.phx.gbl
| Xref: cpmsftngxa08.phx.gbl microsoft.public.dotnet.languages.vb:97292
| NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
| X-Tomcat-NG: microsoft.public.dotnet.languages.vb
|
| I create my own control with some image property. It
| works fine when I set or change some images into this
| property through Properties Window at Design time. The
| problem is I can't set it to None or nothing at Design
| time like when set none by hitting Delete button in the
| image in properties window in Label control. Does it has
| to declare something or I do something wrong
|