Doggo120 Posted April 25, 2012 Posted April 25, 2012 (edited) How to sort List of Buttons Hey beautiful people! I'm working on a User Control, and I've created a List variable like this: Private vKey As New List(Of Button) Then I search for all the buttons in the user control and add them: Private Sub AddToList() For Each Key As Control In Me.Controls If TypeOf (Key) Is Button Then vKey.Add(Key) End If Next End Sub I'd want to sort the list by the button names ('cause they're added in some unknown order) Thanks! Edited April 25, 2012 by Doggo120 Quote
Leaders snarfblam Posted April 25, 2012 Leaders Posted April 25, 2012 Re: How to sort List of Buttons The Sort method comes in handy: Sub SortButtons() vKey.Sort(AddressOf SomeButtonCompareFunction) End Sub Function SomeButtonCompareFunction(ByVal A As Button, ByVal B As Button) As Integer ' You probably want to perform a string compare of the two button's names here. End Function Quote [sIGPIC]e[/sIGPIC]
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.