Microsoft
Software
Hardware
Network
Question : Combobox values default
Hi Am developing windows application where in am loading the combo box as follows
cmbtitleid.BindingContext = new BindingContext();
cmbtitleid.DataSource = datasourcetitle;
cmbtitleid.ValueMember = "TITLEID";
cmbtitleid.DisplayMember = "DECRIPTION";
cmbtitleid.SelectedIndex = -1;
Here, what I want to do is, the datasource has only 1 record, then it should be displayed in combobox by default. If there are more than 1 record, then cmbtitleid.SelectedIndex = -1;
should work as is. How do i alter this code to achive what i want
Answer : Combobox values default
almost forgot: if there's a possibility that there's no data returned, do
else if(cmbtitleid.Items.Count == 1)
instead of the else-statement.
Random Solutions
Difference between 3G and 3G Broadband
What's the best way to modify bitfields
How do I alter this flash file?
Oracle SQL: why this regular expression doesn't work?
Excel: Programmatically determine if Trust Access To VB Project has been set
How to change the regualr property to the automated property for which the automated property is working fine
Storing and retrieving text files to blobs
How do I show comments without showing tracked changes via code (C#)?
IAT patching, problem when calling back to original target function?
VM ware esxi 4 hungs with a massg "VM ware loaded sucsessfuly"