|
-
Jul 8th, 2004, 11:31 AM
#1
Thread Starter
Hyperactive Member
How to manually populate a DataComboBox [VB6]
Given a Data Combo Box [Dcb] I need to find a way to populate it manually with 3 fields (Type, Category, Location).
If this was an ordinary Combo Box I would do something like “ComboBox.Additem “Type”, 0” however that option does not seems available with Data Combo Boxes.
You may ask why am I using a Data Combo Box, it seems to be the only combo box that the Dcb_Change() event is loaded by selecting one of the items from the dropdown. The regular Combo box does not, it waits for the user to actually Type something in the field (which should be disabled because he should only have to choose from the list)
-
Jul 8th, 2004, 11:35 AM
#2
in a regular combobox, set the style to 3 and the user wont be able to type their own stuff in the box, only be able to select from the dropdown list. And the click event is the event that fires when they select an item, either by using the mouse or by using they keyboard to change the selection
-
Jul 8th, 2004, 12:15 PM
#3
Thread Starter
Hyperactive Member
I tried that already (and just tried it again to be 100% sure).
The Combox (Style = 2: Dropdown List) is perfect except that when I change the selected value the _Change() event is not fired.
Should I be using a different event?
-
Jul 8th, 2004, 12:24 PM
#4
He already mentioned it... Click event
-
Jul 8th, 2004, 12:38 PM
#5
Originally posted by kleinma
And the click event is the event that fires when they select an item, either by using the mouse or by using they keyboard to change the selection
-
Jul 8th, 2004, 12:40 PM
#6
yup they said it
sorry i said set the style to 3 when you are right it is 2, i was thinking 3rd style, which of course is 2 in the 0 based index
-
Jul 8th, 2004, 01:29 PM
#7
Thread Starter
Hyperactive Member
Completly my mistake, read way too fast and didn't even notice.
Sorry for the misunderstanding on my part.
Thank you all for the help 
Now this brings up another issue, using Style 2 doesn't allow me to start with the Combo Box empty (CB.TEXT = "").
VB6 will not allow me to erase the generic CombBox1 name in the TEXT property (just wont let me, I can however in Style 0) and if I try via code (CB.TEXT = "") I get an error saying that it is READ ONLY.
Any clues how to fix this?
I just want it to start blank... Or at least let me choose what it says.
Last edited by Shaitan00; Jul 8th, 2004 at 01:34 PM.
-
Jul 8th, 2004, 01:38 PM
#8
when using style 2:
Combo1.ListIndex = -1
will clear the combobox
Combo1.Text = "HELLO"
will work for setting the text ONLY IF the item "HELLO" actually is in the list
-
Jul 8th, 2004, 02:14 PM
#9
Thread Starter
Hyperactive Member
Works like a charm but, as usual when coding, causes another problem.
It seems that if, for example, we have selected something other then listindex = -1 (user chose 1st item), and proceed to hit the CLEAR key (should clear all fields) I will try to reset CB.Listindex = -1 to make it blank again however this launches the CLICK EVENT for that Combo Box thus causing a lot of issues and finally crashing the application.
Is there another way to blank out the ComboBox or disable the Click Event when doing a Clear?
-
Jul 8th, 2004, 02:42 PM
#10
why not just check in the clickevent to make sure the listindex is >= 0 ????
-
Jul 8th, 2004, 02:51 PM
#11
Thread Starter
Hyperactive Member
Now that was a damn good idea.
Thanks, everything is working perfectly.
I owe you one
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|