|
-
Feb 11th, 2004, 06:44 AM
#1
Thread Starter
New Member
combobox
Hello.
How can I select an option of a combobox dynamicaly?
sort of comboBox1.selectItem(5);
and how can I make the combobox not editabe?... that is... the user can use the combobox for choosing the available options, but not to enter new text
thanks
-
Feb 11th, 2004, 07:45 AM
#2
Junior Member
Re: combobox
Originally posted by pilsjart
How can I select an option of a combobox dynamicaly?
sort of comboBox1.selectItem(5);
Sheet1.ComboBox1.ListIndex = iVal
where iVal is the number you want to select, so in your example iVal could be replaced with 5
and how can I make the combobox not editabe?... that is... the user can use the combobox for choosing the available options, but not to enter new text
Private Sub ComboBox1_Change()
If Sheet1.ComboBox1.ListIndex = -1 Then Sheet1.ComboBox1.Text = ""
End Sub
basically if new text is entered it won't be found in the combo box and will therefore have an index value of -1, when this happpens just clear the box..
Simple but effective
"much to learn you still have"
-
Feb 11th, 2004, 08:01 AM
#3
Thread Starter
New Member
thanks...
about the:
Private Sub ComboBox1_Change()
If ComboBox1.ListIndex = -1 Then ComboBox1.Text = ""
End Sub
can It simply remain in the same ListIndex position?
that is, when I type any text, I want the comboBox to remain in te same selection without moving to the position -1.
Is it possible?
-
Feb 11th, 2004, 08:17 AM
#4
Junior Member
it is possible but basically it would require you to store the value of the current index and only change the index value when the current value is greater than -1
-1 basically shows that no item is selected.
"much to learn you still have"
-
Feb 11th, 2004, 08:45 AM
#5
Frenzied Member
If you don't want the user to be able to edit/add items, set the dropdownstyle to dropdownlist (Think this works in VBA, it's in VB, anyway. Hard to keep the differences between VBA, VB6 and VB.Net separate sometimes).
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
|