Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Name Property
 

Name Property

Hi

I have a custom control that is inherited from System.Windows.Forms.Control.
I want to do some custom processing when the Name of the control is set. But inside the constructor,a reference to the Name yields a blank value i.e. "".
Can u tell me when is the name of the Control actually set.
Also whenever the user changes the Name of the control from the propertyGrid I want to have some kind of processing done. 
But there is no event of the type OnNameChanged.

Kindly let me know wot can be done

Regards
Vikas
MigrationUser 1  Friday, March 14, 2003 12:19 AM
Don't know if this is still an issue, but you could declare your "own" name:


Private mName as String

Public Shadows Property Name () as string.
  Get
    if mName is Nothing then
      mName = mybase.Name      
      DoStuff
    end if
    return mName
  end Get
  Set (byval value as string)
    mName = value
    DoSomeOtherStuff
  End Set
End Property
MigrationUser 1  Friday, March 14, 2003 7:59 AM
At design time, get a reference to the IComponentChangeService service and use its ComponentRename event. In your function that handles the event, check if the component being renamed is yours, and go from there.
MigrationUser 1  Monday, March 24, 2003 5:09 AM
Hi
Ya it did work, i mean with the IComponentChangeService, i get to do custom processing when the Name is changed.
But now i am facing another problem. Whenever I change the name, the eventhandler i have used is repeatedly called 5-10 times. same goes for IComponentChangeService.Added event.
Both the event handlers are called repeatedly.can u tell me wot can be done abt it.

thanx again 

vikas
MigrationUser 1  Friday, April 11, 2003 6:48 AM
Are you hooking the handler up more than once by accident?  You should only get called once per rename or component add.
MigrationUser 1  Tuesday, April 22, 2003 6:11 PM

You can use google to search for other answers

Custom Search

More Threads

• VS.NET designer support for collections
• Error in SELECT clause: expression near '['
• Event handling in design time mode
• VB2005-Express: Display Grid in Windows Forms Designer
• Immediate window only lists first 100 properties
• Control development tricks & traps
• Drag drop source file from Solution Explorer onto a form in designer
• Disable crtl and drag operation in designer host
• Theming a Windows Form
• Design control added through code