Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 10-02-2004, 02:59 PM   #1
Member (7 bit)
 
Join Date: Jun 2003
Location: Israel
Posts: 92
Send a message via ICQ to M.D.
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?
M.D. is offline   Reply With Quote
Old 10-06-2004, 07:54 AM   #2
Come in Ray...
 
faulkner132's Avatar
 
Join Date: Sep 2004
Posts: 1,668
Use the .text method.

Ex. ComboBox1.text = "Default choice"
faulkner132 is offline   Reply With Quote
Old 10-06-2004, 12:12 PM   #3
Member (7 bit)
 
Join Date: Jun 2003
Location: Israel
Posts: 92
Send a message via ICQ to M.D.
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!!
M.D. is offline   Reply With Quote
Old 10-06-2004, 12:34 PM   #4
Professional gadfly
 
doctorgonzo's Avatar
 
Join Date: Jan 2002
Location: Minneapolis, MN
Posts: 6,364
Send a message via MSN to doctorgonzo
I would guess that you use the .DefaultValue property.

How are you dynamically adding the values?
doctorgonzo is offline   Reply With Quote
Old 10-06-2004, 01:30 PM   #5
Member (7 bit)
 
Join Date: Jun 2003
Location: Israel
Posts: 92
Send a message via ICQ to M.D.
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
M.D. is offline   Reply With Quote
Old 10-06-2004, 01:40 PM   #6
Professional gadfly
 
doctorgonzo's Avatar
 
Join Date: Jan 2002
Location: Minneapolis, MN
Posts: 6,364
Send a message via MSN to doctorgonzo
What version of VB are you working with then?
doctorgonzo is offline   Reply With Quote
Old 10-06-2004, 01:48 PM   #7
Member (7 bit)
 
Join Date: Jun 2003
Location: Israel
Posts: 92
Send a message via ICQ to M.D.
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....
M.D. is offline   Reply With Quote
Old 10-06-2004, 02:07 PM   #8
Professional gadfly
 
doctorgonzo's Avatar
 
Join Date: Jan 2002
Location: Minneapolis, MN
Posts: 6,364
Send a message via MSN to doctorgonzo
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?
doctorgonzo is offline   Reply With Quote
Old 10-06-2004, 07:22 PM   #9
Member (7 bit)
 
Join Date: Jun 2003
Location: Israel
Posts: 92
Send a message via ICQ to M.D.
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
M.D. is offline   Reply With Quote
Old 10-07-2004, 07:47 AM   #10
Member (7 bit)
 
Join Date: Jun 2003
Location: Israel
Posts: 92
Send a message via ICQ to M.D.
Listen i dont have this property?
You checked you have it? How you have it and i am not...
M.D. is offline   Reply With Quote
Old 10-07-2004, 08:08 AM   #11
Come in Ray...
 
faulkner132's Avatar
 
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")
Make sure you are on the latest service pack... if it doesn't work then I don't know why.
faulkner132 is offline   Reply With Quote
Old 10-07-2004, 08:38 AM   #12
Member (7 bit)
 
Join Date: Jun 2003
Location: Israel
Posts: 92
Send a message via ICQ to M.D.
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!!!!!!
M.D. is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 06:54 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2