|
-
Apr 26th, 2006, 03:17 PM
#1
Thread Starter
Junior Member
Drop Down / Dataset , insert blank in top ?
I would like to inset blank or "select" in the top the dropdown,
cbxStoreCategory.DataSource = categoriesBindingSource2;
cbxStoreCategory.DisplayMember = "CategoryCode";
//cbxStoreCategory.Items.Insert(0, "--Select--");
however I cannot do this way, any suggestion ?
-
Apr 26th, 2006, 05:55 PM
#2
Re: Drop Down / Dataset , insert blank in top ?
If you set the DataSource of a control then that control is bound to that data. It will display the data it is bound to and only the data it is bound to. If you want it to display a blank entry then you would have to add a blank entry to the data source. It is generally incorrect to do so though. Adding a blank entry implies that there is an entry that is blank that the user can select. That is not the same thing as them selecting no entry at all. If you want to clear the selection of a bound combo box then you need to set the SelectedIndex to -1, which equates to no selection. If you need to allow the user to do this themselves then I usually handle the KeyDown event and test for the Delete key and/or provide a right-click menu with a Clear option.
Also, you should use the term "ComboBox" and not "dropdown". There is a similar control called "DropDownList" in ASP.NET so if you don't use the correct name then it may not be clear that you aren't creating a Web app with a DropDownList. Terminology is important.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|