Results 1 to 7 of 7

Thread: Sorting Buttons

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2013
    Posts
    7

    Post Sorting Buttons

    Hi There,

    This may be a bit too advanced, but is there anyway to sort buttons by Alpheabtical order?

    Thank You

    J Mahone

  2. #2
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,508

    Re: Sorting Buttons

    What do you mean sort buttons? Do you mean there position on the form?

  3. #3
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    Re: Sorting Buttons

    I don't really follow either, but I'll throw this out....
    create a sortedlist(of String,Button) and put all of your buttons in it using the button name for the key, and the button proper for the value.
    Last edited by kebo; Jan 25th, 2014 at 01:40 PM.
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  4. #4

    Thread Starter
    New Member
    Join Date
    Jul 2013
    Posts
    7

    Post Re: Sorting Buttons

    Name:  Screen Shot 2014-01-26 at 10.03.19.png
Views: 184
Size:  38.0 KBHI There,

    Sorry if I was being confusing, but I am trying to make a seating plan application, Name:  Screen Shot 2014-01-26 at 10.03.19.png
Views: 184
Size:  38.0 KB

    (See Image), and when I click on the 'Sort by Surname' tab, all of the buttons are sorted by alpheabetical order.

    Do I use the same method that you have said?

    Thank You

    J Mahone

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Sorting Buttons

    Don't even bother sorting the Buttons. Just sort the names. Sort the names and then loop through the Buttons and put the names on them in turn, e.g.
    Code:
    names.Sort()
    
    For i = 0 to buttons.Count - 1
        buttons(i).Text = names(i)
    Next
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6

    Thread Starter
    New Member
    Join Date
    Jul 2013
    Posts
    7

    Re: Sorting Buttons

    Hi There,

    Sorry, but I am a bit of a newbie at this, and I do not understand the code which you have provided.

    Could you please explain what the coding means and how to type it up, that would be great.

    Thank You

    J Mahone

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Sorting Buttons

    The code means that you have a list of names and a list of buttons, you sort the names and then you loop over both lists, displaying each name on the corresponding button. Think about it. If you had a room full of chairs and a name tag on each one, if you wanted to put the names on the tags in alphabetical order would you move the chairs or just the name tags? This is pretty much exactly the same thing.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Tags for this Thread

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