how to sort bound dropdown list vb.net

  • Thread starter Thread starter dev guy
  • Start date Start date
D

dev guy

hi

I have a drop-down list (combobox) bound to a dataset, on a windows form,

I want the displayed strings in the list to be sorted. so I have set
ds.defaultview.sort="field name"

however this does not work.

Can somebody throw some light on this behaviour?

warm regards
 
Set the DefaultView's Sort property, on the appropriate DataTable, to
whatever you like and then set the ComboBox's DataSource property to the
DefaultView of the DataTable:

myDataTable.DefaultView.Sort = "field name ASC"
ComboBox1.DataSource = myDataTable.DefaultView
ComboBox.DisplayMember = "field name"
 
Back
Top