Author |
Message |
Scott Moo #1 / 7
|
 Combobox (Dropdown List: Style=2)
I have a question regarding a dropdown list. I do the following List1.Additem "" List1.Additem "1" List1.Additem "2" List1.Additem "3" List1.Text = "2" and it works fine. But if I try: List1.Text = "" then I get the Text property is read only error. The empty string is in the list, why can't the lists text property be set to it?
|
Sun, 09 Jan 2005 07:26:35 GMT |
|
 |
Frank Ad #2 / 7
|
 Combobox (Dropdown List: Style=2)
Quote: >I have a question regarding a dropdown list. >I do the following >List1.Additem "" >List1.Additem "1" >List1.Additem "2" >List1.Additem "3" >List1.Text = "2" >and it works fine. But if I try: >List1.Text = "" >then I get the Text property is read only error. The empty string is >in the list, why can't the lists text property be set to it?
The text property is used for lookups and retrieving the current text. It will not accept an empty string as that would be somewhat silly to search for in a control like the Combo box. :-) Use a single space instead, if you have to. Regards, Frank
|
Sun, 09 Jan 2005 07:57:25 GMT |
|
 |
Randy Birc #3 / 7
|
 Combobox (Dropdown List: Style=2)
Setting the text property on a style-2 combo will lead to errors if the list does not contain an exact match to the string assigned to the text property. For all intents and purposes, you consider setting the text property as poor practice with a style-2 combo. To clear the selection with a style-2 combo (or list for that matter), set the listindex property to -1. -- Randy Birch MVP Visual Basic http://www.mvps.org/vbnet/ Please respond only to the newsgroups so all can benefit.
| I have a question regarding a dropdown list. | | I do the following | | List1.Additem "" | List1.Additem "1" | List1.Additem "2" | List1.Additem "3" | List1.Text = "2" | | and it works fine. But if I try: | | List1.Text = "" | | then I get the Text property is read only error. The empty string is | in the list, why can't the lists text property be set to it?
|
Sun, 09 Jan 2005 11:18:31 GMT |
|
 |
Scott Moo #4 / 7
|
 Combobox (Dropdown List: Style=2)
The combobox (dropdown list style) in VBA allows you to add "" to the list and set it's text property to it.... it is too bad it can't be done on the combobox in VB.... Quote:
> Setting the text property on a style-2 combo will lead to errors if the list > does not contain an exact match to the string assigned to the text property. > For all intents and purposes, you consider setting the text property as poor > practice with a style-2 combo. > To clear the selection with a style-2 combo (or list for that matter), set > the listindex property to -1. > -- > Randy Birch > MVP Visual Basic > http://www.mvps.org/vbnet/ > Please respond only to the newsgroups so all can benefit.
> | I have a question regarding a dropdown list. > | > | I do the following > | > | List1.Additem "" > | List1.Additem "1" > | List1.Additem "2" > | List1.Additem "3" > | List1.Text = "2" > | > | and it works fine. But if I try: > | > | List1.Text = "" > | > | then I get the Text property is read only error. The empty string is > | in the list, why can't the lists text property be set to it?
|
Mon, 10 Jan 2005 01:30:04 GMT |
|
 |
Randy Birc #5 / 7
|
 Combobox (Dropdown List: Style=2)
| The combobox (dropdown list style) in VBA allows you to add "" to the | list and set it's text property to it.... it is too bad it can't be | done on the combobox in VB.... Well, I don't know about that. Personally I find it easier to manipulate the list index than dink around with the text property, regardless of the combo's style (in VB). -- Randy Birch MVP Visual Basic http://www.mvps.org/vbnet/ Please respond only to the newsgroups so all can benefit.
| The combobox (dropdown list style) in VBA allows you to add "" to the | list and set it's text property to it.... it is too bad it can't be | done on the combobox in VB.... |
| > Setting the text property on a style-2 combo will lead to errors if the list | > does not contain an exact match to the string assigned to the text property. | > For all intents and purposes, you consider setting the text property as poor | > practice with a style-2 combo. | > | > To clear the selection with a style-2 combo (or list for that matter), set | > the listindex property to -1. | > | > | > -- | > | > Randy Birch | > MVP Visual Basic | > http://www.mvps.org/vbnet/ | > Please respond only to the newsgroups so all can benefit. | > | >
| > | I have a question regarding a dropdown list. | > | | > | I do the following | > | | > | List1.Additem "" | > | List1.Additem "1" | > | List1.Additem "2" | > | List1.Additem "3" | > | List1.Text = "2" | > | | > | and it works fine. But if I try: | > | | > | List1.Text = "" | > | | > | then I get the Text property is read only error. The empty string is | > | in the list, why can't the lists text property be set to it?
|
Mon, 10 Jan 2005 09:21:32 GMT |
|
 |
Frank Ad #6 / 7
|
 Combobox (Dropdown List: Style=2)
Quote:
>| The combobox (dropdown list style) in VBA allows you to add "" to the >| list and set it's text property to it.... it is too bad it can't be >| done on the combobox in VB.... >Well, I don't know about that. Personally I find it easier to manipulate the >list index than dink around with the text property, regardless of the >combo's style (in VB).
Actually, i find the text property is handy at times and that error it throws is trappable. What i wouldn't do is to add an empty string to a combo or a listbox. Regards, Frank
|
Mon, 10 Jan 2005 10:06:59 GMT |
|
 |
Ray Insalac #7 / 7
|
 Combobox (Dropdown List: Style=2)
Well don't I fell stupid. I have been tring to find a clean way to do that for YEARS!!!! Quote:
> Setting the text property on a style-2 combo will lead to errors if the list > does not contain an exact match to the string assigned to the text property. > For all intents and purposes, you consider setting the text property as poor > practice with a style-2 combo. > To clear the selection with a style-2 combo (or list for that matter), set > the listindex property to -1. > -- > Randy Birch > MVP Visual Basic > http://www.mvps.org/vbnet/ > Please respond only to the newsgroups so all can benefit.
> | I have a question regarding a dropdown list. > | > | I do the following > | > | List1.Additem "" > | List1.Additem "1" > | List1.Additem "2" > | List1.Additem "3" > | List1.Text = "2" > | > | and it works fine. But if I try: > | > | List1.Text = "" > | > | then I get the Text property is read only error. The empty string is > | in the list, why can't the lists text property be set to it?
|
Tue, 11 Jan 2005 07:52:56 GMT |
|
|