|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
#1 |
|
Member (7 bit)
|
Visual Basic - combo box
I am inserting values dynamically into some combo box.
I would like to make some of them to be the default value of the combo box, displayed if nothing was chosen, instead of the blanc choice. How can this be done plz? |
|
|
|
|
|
#2 |
|
Come in Ray...
Join Date: Sep 2004
Posts: 1,668
|
Use the .text method.
Ex. ComboBox1.text = "Default choice" |
|
|
|
|
|
#3 |
|
Member (7 bit)
|
This solution wont work.
Because i use drop box that it is imposible to write into, only to choose values (it is style = 2). Thus the Text property when assign like you said is reported as error: read only value (or something this kind). What you said will work with style = 0, which is a drop box that NEW values may be entered there. But this is not what i need. (Anothe rsolution i came of is: making it style = 0, making locked property to true, and then the user may click on it, as to edit it (cursor the same) but wont be able to change actually. It is very ugly solution...) plz help!! |
|
|
|
|
|
#4 |
|
Professional gadfly
|
I would guess that you use the .DefaultValue property.
How are you dynamically adding the values? |
|
|
|
|
|
#5 |
|
Member (7 bit)
|
Dynamically adding values:
Yout_Combo_Box_Name.AddItem Your_Item_String And if this combo box had .DefaultValue property, I would been here asking ![]() It doesnt have one |
|
|
|
|
|
#6 |
|
Professional gadfly
|
What version of VB are you working with then?
|
|
|
|
|
|
#7 |
|
Member (7 bit)
|
6 !!!
Are you tellong me in .Net its better with this kind of **** ?!?! If so, will it be deficult for me to transfer my project there? OP is it a pain in the ass? I mean i use access db and some other stuff here.... |
|
|
|
|
|
#8 |
|
Professional gadfly
|
One solution I have seen is to set the .SelectedIndex property of the value you want to be default on the OnLoad event for the form the combo box is on. At what point are you adding the values?
|
|
|
|
|
|
#9 |
|
Member (7 bit)
|
This is a good idea
and a new one, i will try and report.I am adding them at different parts, but it wont be a problem |
|
|
|
|
|
#10 |
|
Member (7 bit)
|
Listen i dont have this property?
You checked you have it? How you have it and i am not... |
|
|
|
|
|
#11 |
|
Come in Ray...
Join Date: Sep 2004
Posts: 1,668
|
In VB6 if the style is set to 2 (dropdown list), you can set the .Text property as long as the text does exist. I just tested it and it worked.
Here is the code I used: Code:
Combo1.Clear
Combo1.AddItem "test1"
Combo1.AddItem "test2"
Combo1.AddItem "test3"
Combo1.AddItem "test4"
Combo1.Text = InputBox("enter value")
|
|
|
|
|
|
#12 |
|
Member (7 bit)
|
GOD BLESS YOU!!!!
I was trying to do the same!!!! BUT i tried the text property assignment first!! now that i put it after the add item, it works. ohh man you dont know how long i mess with this. thank you so much!!!!!! |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|