Combobox value reset

Sergionik

Member
Joined
Sep 22, 2010
Messages
7
Programming Experience
Beginner
Hi!

I use Combobox with property "DropDownStyle=DropDownList"
Combobox is filled with values, e.g. "Tables", "Queries", "Macros".

Sometimes I should reset value and I write code:
PHP:
Combobox1.Text=""

But it doesn't work, i.e. if value has been chosen "Queries", after performance of a code value doesn't change
Where I was mistaken?
 
The Text property should generally only be used when DropDownStyle is DropDown, in which case it behaves just like the text of a TextBox. If you don't want any item selected in the ComboBox you should set the SelectedItem to Nothing or the SelectedIndex to -1.
 
Thanks, jmcilhinney!
It's working.

And I have thought up an alternative variant...
As Combobox obtains the data from the table I have added in the table record "- - isn't chosen - -".
Now, when I should Combobox reset value, I actually choose value "- - isn't chosen - -".
 
I always find it interesting that so many people want to put a "dummy" entry into a ComboBox yet the same people are more than happy to leave a TextBox empty. If the user can work out that they are supposed to enter something into an empty TextBox, surely they can also work out that they are supposed to select something from an empty ComboBox.
 
Back
Top