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"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top