if i have a form with 100 button and i want to rename them all in sequence like
btn0,btn1 ....
is there a way to do this in code or i have to do it manualy
Printable View
if i have a form with 100 button and i want to rename them all in sequence like
btn0,btn1 ....
is there a way to do this in code or i have to do it manualy
You need to do this manually.
is there any easy way to do it than name it button by button
At runtime, you'll have to do it manually as kevin said.
vbnet Code:
Dim btn As Button For i As Int32 = 0 to 99 btn = New Button() btn.Name = "Button" & i.ToString() btn.Size = New Size(0, 0) btn.Location = New Point(x,y) [control].Controls.Add(btn) Next
etc etc.. You'll have to calculate where the buttons go though, which generally isn't to difficult. Just so long as there uniform.
You can do that at runtime iterating form's control collection using GetType to identify your buttons.
If you had MZ-Tools (third party IDE add-in) you could do it easily. In short the add-in has a control assistant which looks like
http://kevininstructor.home.comcast....DotNet/MZ1.jpg
which allows you to change the name, press enter move down to the next control until done. Pressing Enter updates the control name.
Side note: There are a good deal of nice features in this tool but my most used is their tab assistant and enhanced find dialog. Been using this tool for the past five or six year and has easily paid for itself (50 dollars when we purchased it) many times over.