|
-
Jan 23rd, 2008, 03:58 PM
#1
Thread Starter
Hyperactive Member
[2008] Sort Class
Can anybody show me how you override the sort property of the listbox in a class and the usage of it please ?
Thanks
-
Jan 23rd, 2008, 04:01 PM
#2
Re: [2008] Sort Class
Here's a link that shows how to do it:
Custom Sorter
-
Jan 23rd, 2008, 04:20 PM
#3
Thread Starter
Hyperactive Member
Re: [2008] Sort Class
Thanks, i can see how it works but i am after the code and usage of overriding a property of the listbox. I have this but how do you use it with Listbox1 on the form.
Code:
Public Class MySort
Inherits ListBox
Protected Overrides Sub Sort()
'what is this mybase.sort ?
MyBase.Sort()
'Im thinking the code for the descending sort goes here
End Sub
End Class
Thanks.
-
Jan 23rd, 2008, 04:25 PM
#4
Re: [2008] Sort Class
To start, you'll need to create a UserControl for the MySort object, remove the Listbox1 and replace it with a MySort object. Or you might be able to create the MySort object in a method, do all the sorting stuff and then go ListBox1 = CType(mysort_object_you_created, ListBox) - not sure if that would work or not, but I think it would.
For the override Sort method ,when you override a method, the first thing it does is call the base method that gets overriden. I'm not sure if this can be removed or not, but I think it throws an error if you try. After that, you'd put in the code for your custom sorting.
-
Jan 23rd, 2008, 09:02 PM
#5
Re: [2008] Sort Class
Have you read the documentation for the ListBox.Sort method? It provides a code example.
When overriding methods you often call the overridden base member. This gives you the default implementation of the method, which you can then customise by adding more code. In this case you don't want the default implementation though, so don't call the overridden base member.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|