Swaping
-
I m using combobox to get values from database. I want to swap two values of dropdwon list with each other in an event. Can any one give me idea of that event.
-
I m using combobox to get values from database. I want to swap two values of dropdwon list with each other in an event. Can any one give me idea of that event.
Which values? Is it to be sequential e.g. swap item at index 0 with item at index 1? Or non-sequential e.g. swap item at index 0 (or any other) with any other item in the index (swap item 4 with 9, 2 with 1, 6 with 13)? Either way the event that you're looking for is the SelectedIndexChanged event.
-
I m using combobox to get values from database. I want to swap two values of dropdwon list with each other in an event. Can any one give me idea of that event.
Safecom wrote:
I m using combobox to get values from database.
No, you are using a DataProvider to get values from the database. Those values are provided to you in a stream. You can put those values into various containers, eg. a DataTable, an Array of List Objects, etc. which can then be fed or bound to your control. They should be encapsulated in a list of business objects, (preferably using a list type that implements IList - ArrayList is good) which is then manipulated (sorted according to your business rules, which may change momentarily by user gestures such as clicking radio buttons, checkboxes, etc.) and then presented to the user in the ComboBox. You may need to add a suitable sort key to your business object to help with the re-sorting/swapping. You can do all that off the DropDown event if necessary, but you will take a performance hit. It would be better to evaluate your conditions beforehand if possible, using other control events, and re-sort the list (and rebind the list to the control) before the user drops it down. SelectedIndexChange is too late. The user has already seen the list.