How to make an item to be selected by default in combobox
-
Hi, I am retrieving some values from database & populating them in a combobox.Prior to populating the values from the combobox,i manually added an item as "All" and i want that this item should be the default selected item(with index -1) when the values will be populated from the database into the combobox. Can anybody help me how to do this..? Thanks in advance
i m Pradip Kishore
-
Hi, I am retrieving some values from database & populating them in a combobox.Prior to populating the values from the combobox,i manually added an item as "All" and i want that this item should be the default selected item(with index -1) when the values will be populated from the database into the combobox. Can anybody help me how to do this..? Thanks in advance
i m Pradip Kishore
Pradip Kishore wrote:
I am retrieving some values from database & populating them in a combobox.Prior to populating the values from the combobox,i manually added an item as "All" and i want that this item should be the default selected item(with index -1)
You can do that, provided you don't insist on the with index -1 requirement (-1 is used to mark the no selection state). If you add te "All" item manually (and the combo has NOT the sort style set) then it will have index 0, hence you just select item 0 to perform the task. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
-
Pradip Kishore wrote:
I am retrieving some values from database & populating them in a combobox.Prior to populating the values from the combobox,i manually added an item as "All" and i want that this item should be the default selected item(with index -1)
You can do that, provided you don't insist on the with index -1 requirement (-1 is used to mark the no selection state). If you add te "All" item manually (and the combo has NOT the sort style set) then it will have index 0, hence you just select item 0 to perform the task. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
Hi Thanks for your answr. But my requirement is that when the page will be loaded then the default selected item in the combobox should be "all" i added "all" as combobox.iteams.add("all") now i want to make "all" as my default selected item of the combobox. Please revert back soon.
-
Hi Thanks for your answr. But my requirement is that when the page will be loaded then the default selected item in the combobox should be "all" i added "all" as combobox.iteams.add("all") now i want to make "all" as my default selected item of the combobox. Please revert back soon.