|
-
May 21st, 2013, 09:12 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] Listbox Odd behavior
I have a listbox that is bound to a datasource and is filtered as below. The odd behavior is that it doesn't sort correctly as in 1,2,6,7,3,4,5. Any idea why this could be happening?
How the table is filled:
Code:
Me.ERV_ExhibitsTableAdapter.Fill(Me.ERVDataSet.ERV_Exhibits)
My filter code.
Code:
Private Sub cmbLocation_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles cmbLocation.SelectedIndexChanged
ERV_ExhibitsBindingSource.Filter = String.Format("Location = '{0}' AND Exhibit = '{1}'", cmbLocation.Text, cmbQualifyingCritera.Text)
End Sub
Life is about making some things happen, not waiting around for something to happen.
-
May 21st, 2013, 09:26 AM
#2
Thread Starter
Fanatic Member
Re: Listbox Odd behavior
I compact and repair of the db fixed the problem. Still do not know why but it's fixed.
Life is about making some things happen, not waiting around for something to happen.
-
May 21st, 2013, 02:26 PM
#3
Re: [RESOLVED] Listbox Odd behavior
Filter isn't the same thing as sorting. When you use BindingSource.Filter, you return a group of rows that match a certain criteria. In this case you where returning rows where your column 'Location' matches cmbLocation.Text and where your column 'Exhibit' matches cmbQualifyingCritera.Text. If you wanted to sort those returned rows you'd call BindingSource.Sort. Let's say you wanted to sort the 'Location' column, it would look like this:
Code:
ERV_ExhibitsBindingSource.Sort = "Location"
If you wanted to sort by Location and then by Exhibit, the sort string would be a bit different:
Code:
ERV_ExhibitsBindingSource.Sort = "Location, Exhibit"
You can also specify how the rows sort by adding "ASC" for ascending or "DESC" for descending at the end of your column, using the sorting by location and then by exhibit, if you wanted the sorting to be descending then it would look like this:
Code:
ERV_ExhibitsBindingSource.Sort = "Location DESC, Exhibit DESC"
Last edited by dday9; May 21st, 2013 at 02:29 PM.
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
|