How can i make my combobox not editable ?
I only want the users to be able to pick from the list, not edit the items in it. I tried to lock it, but then i couldnt choose any item at all..
thnx for any help
Printable View
How can i make my combobox not editable ?
I only want the users to be able to pick from the list, not edit the items in it. I tried to lock it, but then i couldnt choose any item at all..
thnx for any help
Hi, dialafc.
Set Style property to 2-Dropdown List.
Larisa
Hi, setting the property causes you to be unable to add items to the drop-down box
programmatically.
I use:
MsgBox "No Typing allowed here. Please select only!"
Combo43.Text = ""
regards,
AJM
As far as I know Abie is wrong since you can always add items to the list programmatically (even it is a drop-down listbox only). What he may mean is it is impossible to set the .Text property of the combobox to something that isn't in the dropdown list..
------------------
Mark "Buzby" Beeton
VB Developer
[email protected]
Hi, I forgot to tell.
Put this on the KeyPress function
Private Sub Combo43_KeyPress(KeyAscii As Integer)
MsgBox "No Typing allowed here. Please select only!"
Combo43.Text = ""
End Sub
Regards
AJM
The problem with that is really devious users (and most of them are) can copy text from somewhere and (providing they use the popup menu on the right mouse button) paste it into your combobox - Abie's Keypress code would never get run.
Use a combobox, style set to 2-dropdown list. Now users can only select text in the dropdown - if you want to clear the box, use
Combo1.ListIndex=-1
in code. If you must you could always attach that to a keydown event (eg vbKeyDelete)
eg;
Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyDelete Then Combo1.ListIndex = -1
End Sub
Now, if someone presses DELETE when the combobox has the focus it will be cleared.
That ought to do it.
:D
------------------
Mark "Buzby" Beeton
VB Developer
[email protected]