Ccommon controls toolbox, new objects names

jbl_ks

Member
Joined
Dec 16, 2010
Messages
24
Programming Experience
Beginner
I am very new to Visual Basic.net. I am using Visual Studio 2010 and working through the book Beginning Visual Basic.Net 2010-Wiley.
When I add a new button its default new name is Button1, similar for a new List Box, ListBox1 and so on.
Is there an option somewhere or some file to change that will cause a new added button to have the name btn1, a new List box-lst1 and so on for all of the tools in the common controls toolbox?
I have to rename all of them anyway but this would be a handy reminder for me.
I have some code questions that I will try to post to the correct forum.
Thanks
 
"btn1" is a better reminder than "Button1" ? :) There is no customization for this in IDE, it is the class name that is used and it is done by the designers default INameCreationService implementation. It is possible to replace this service, though not easily. From my quick research I wrote a 'NameCreatorComponent' that is attached, if you add this .vb file to project (and compile) then and add an instance of the component from Toolbox to a form you'll see for example new buttons added are named BTN1 etc, but only for that form. If you remove the component it reverts to default naming. Interesting to see, yet and I don't know if this can be done easier and more complete. The code for NameCreationService was for the most part copied from documentation.
 

Attachments

  • Renamer.vb.txt
    3.9 KB · Views: 35
Thanks that sounds promising however I just recently started to work with VB.Net and do not know how to add this .vb file to my project.
I made a few stabs at it with no luck.
I am working from a book and looked at the section on Creating Windows Forms User Controls and that didn't help me much.
 
It's on the the Project menu, 'add existing' to add a .vb file (notice I had to give the upload .txt extension) or 'add class' and paste in all text. You also need to 'Add Reference' to System.Design.dll, this library is not available for ".Net 4.0 Client Profile", so you would have to change the projects advanced compile options to ".Net 4.0" (the full package, aka 'advanced' libraries).
You may consider that you really have better things to learn right now than 'hacking' the Designer, it is very advanced. :)
 
Thanks. Yes I won't spend too much time on this for now as the 'simple fix' I had hoped for didn't turn out to be that simple. I will play around with it for a while and get back to baby steps.
 
Back
Top