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
C# HttpWebRequest different pages in same site
HTTP 501/505 on Sharepoint website after installing IIS6 server certificate. Error shows Linksys router responding.
need last three characters of the string
Restoring exchange state to a test environment
whitelist an IP in CISCO ASA5500 firewall
AD 2003 to 2008 Migration Question
Remote monitoring software
move from 2008 to R2 (compared to 2008 from 2005)
3G/4G Sprint broadband for Dell Latitude E4300
Shutting down a domain controller for a few weeks?