Results 1 to 6 of 6

Thread: [RESOLVED] about button name

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2009
    Posts
    534

    Resolved [RESOLVED] about button name

    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

  2. #2
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,714

    Re: about button name

    You need to do this manually.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2009
    Posts
    534

    Re: about button name

    is there any easy way to do it than name it button by button

  4. #4
    Hyperactive Member DavesChillaxin's Avatar
    Join Date
    Mar 2011
    Location
    WNY
    Posts
    451

    Re: about button name

    At runtime, you'll have to do it manually as kevin said.

    vbnet Code:
    1. Dim btn As Button
    2.  
    3. For i As Int32 = 0 to 99
    4.    btn = New Button()
    5.    btn.Name = "Button" & i.ToString()
    6.    btn.Size = New Size(0, 0)
    7.    btn.Location = New Point(x,y)
    8.  
    9.    [control].Controls.Add(btn)
    10. 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.
    Please rate if my post was helpful!
    Per favore e grazie!




    Code Bank:
    Advanced Algebra Class *Update | True Gradient Label Control *Dev | A Smarter TextBox *Update | Register Global HotKey *Update
    Media Library Beta *Dev | Mouse Tracker (Available in VB.net and C#.net) *New | On-Screen Numpad (VB.net) *New

  5. #5
    Addicted Member
    Join Date
    Jan 2012
    Location
    Athens, Greece
    Posts
    143

    Re: about button name

    You can do that at runtime iterating form's control collection using GetType to identify your buttons.

  6. #6
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,714

    Re: about button name

    Quote Originally Posted by new1 View Post
    is there any easy way to do it than name it button by button
    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



    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width