I am Working in C# winform to load values for a combobox from a datatable with some filter query. Following is the code sample,
repeatCombobox.Items.AddRange(dataTable.Select(myFilterStrin));
repeatCombobox.DisplayMember = "EnumerationText";
repeatCombobox.ValueMember = "Value";
But the problem here is, records selected from the table are ‘ordered by value in ascending manner’ by default in the combobox.
I would like to load items as it is in the table (no order) rather than any ordering of value either ascending or desending….. but could not do it till now. Can anybody help me out on this?
try
Edit: if problem is not caused by the combobox’s
Sortedproperty, it’s probably caused by the missing (or non-incremental) primary key in your database table.DataTable.Selectsorts by the primary key by default. If you are not able to add/change the primary key, then you may try adding a new column which has incremental values (maybe you can create a view as well) and use a second parameter in select likedataTable.Select(myFilterStrin, "SortIndex Asc");