Specifying a unique control name when adding at runtime (like the VS IDE)

Posted by user316383 on Stack Overflow See other posts from Stack Overflow or by user316383
Published on 2010-04-14T10:37:19Z Indexed on 2010/04/14 10:43 UTC
Read the original article Hit count: 161

Filed under:
|

hi,

I have a basic IDE for a user control i am building. It allows me to add labels to a panel and move them around, like a very basic form designer.

When I add the controls to the panel at runtime, I'd like to give the control a unique name string like how the VS IDE tracks the controls it already has and adds an extra number when it creates the default control name. I have tried checking the controls collection each time a new control is added, but wasnt sure if there was a good string comparison method to return a name with a unique number on the end that hasn't been used yet.

© Stack Overflow or respective owner

Related posts about .NET

Related posts about vb.net