Click here to Skip to main content
15,922,894 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
Dear All,

I want to know that how microsoft .net framework handle the name of any control.
like when we drag a textbox on a form then its name will be textbox1 and again when drag another textbox its name will be textbox2 and so on.
if we rename any textbox then framework will create the missing name like textbox2 has renamed with mytextbox now when we drag a new textbox then its name will be textbox2.

so i want to know how microsoft handle these things and what is the logic behind it.

I have my own winform and want to create , rename ,delete a control. all things will be done dynamically by programming.

I have a application. with this we can create a new control on the from . now default name of this control will be suppose mytextbox1, mytextbox2, and so on.
now user can delete or rename it. so how can i manage the name same as microsoft.

now i want to implement the functionality for name same as framework.
How should i implement this functionality in my own application

All suggestions are most welcome.

Thanks in anticipation.
Posted
Updated 31-Jul-13 20:51pm
v3
Comments
Joezer BH 1-Aug-13 2:19am    
You just specified the logic, so ... what are you asking?
Maciej Los 1-Aug-13 2:38am    
Sorry, but your question is a bit confusing...
All what we know at this moment is that you want to "implement the functionality" to manage the names of controls, but you do not specify why do you want to do it...

1 solution

I think Microsoft is implementing this functionality by using Prototype Design Pattern. Actually while dragging a control to form it's clone the object. After cloning you can set your own name and behavior to that new Cloned object.It will never affect our original object

http://www.dofactory.com/Patterns/PatternPrototype.aspx[^]

Hope this helps
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900