Data Browser - Viewing Site  Sector 23 Code Bank Logged in as:  Guest  




           


Set Initial Text to DataBound ComboBox
Once you have a ComboBox bound to a datasource, let's say you want to set the text to an initial default value.

If the ComboBox is a basic drop down list (no free text), just set SelectedValue or SelectedIndex.
If it allows text entry, you need a little more:
txt.SelectedText = defaultValue;
txt.Text = defaultValue;
And in that order, don't ask me why.

Also note that you CAN NOT set the text/value UNTIL the ComboBox is physically added to your form. Before that point, it won't work. In fact, Items.Count even returns '0'. Another 'feature' :)

Created By: amos 3/21/2006 5:59:05 PM