catch changing of the Control.Name Property

  • Thread starter Thread starter Weinand Daniel
  • Start date Start date
W

Weinand Daniel

i'd like to monitor changes of the "Control.Name" porperty during
designtime.
if the user changes the name in designer my event musst fire.

i have created a own button control. with an event NameChange.

during runtime it works fine. if the name of the control has changed the
event is fireing.

(for example: designtime name of the button is btnOk, on a second button
i changed the name
during runtime with btnOk.Name = "btnOk2", -> event is ok)

but now i need the same event during desingtime, cause i need to write
the changed
name property into a txt file.

(renaming btnOk to btnOk2 in designer, -> need the event at this place)

how can i bind my event during designtime too?

regards

Daniel
 
Weinand,

I think that the only way you are going to be able to do this is to be
able to write an add in to catch this. At design time, the Name property of
the control is not set, so you would have to hook into the designer to
determine when this happens.

I am curious, what is this needed for?

Hope this helps.
 
hello,

i need this feature for a localization project.
if a own button (or other control) has schanged its name, i will wirte
the name in a txt file. i need this feature for a localization project
with different
resource files. global and local files. if a control is not defined in
global resources,
the name should be written like this in the local.txt:
btnOk.Text = whatever

if the name changes during designtime i will do thefollowing:

replace "btnOk.Text = whatever" with "newName.Text = whatever"

so far so good...... hope you'll understand a bit what im trying.

if a form is localizable in VS, the names and other important things are
changed
automatically by VS if values are changed in designer.
i'd like to clone this feature for my txt file. but only for 2 or 3
attributes.

any ideas or suggestions how to hook into the designer to determine when
the property is set?

cheers
 
Hi Weinand,

If you created your own control what we need to do is to create your own
designer for that control and use a shadow property for the Name. this way
you can catch all the Name changes. Designers use shadow properties that's
why some of the events are not fired during design time.

More info about designers you can find in the following links:
http://www.developerfusion.com/show/4411/2/
http://windowsforms.net/articles/shapedesigner.aspx
http://www.msdn.microsoft.com/libra...brary/en-us/dndotnet/html/custdsgnrdotnet.asp
 
hi,
thank you so much for these informations!
hope to get it running with these informations.

thx a lot.

greetz
 
Back
Top