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
RedirectStandardOutput Not getting all the output
Get property in dynamic Web User Control from an Aspx page
Delete line with duplicate
ADD SIP PRIORTY POLICY TO CISCO ASA
Error 2029 trying to get the serial date of date formatted as "general"
VBS copying Outlook Contact items from Public Folder
Application that changes dates of files at once
sublists margin
Macro to enable a specific add in
20" monitor questionQuestion