|
-
Apr 13th, 2000, 09:04 PM
#1
Thread Starter
Addicted Member
Hi
Just a quick question, is there any way of stopping a user typing text into a combo box, i.e. so they can only select what appears in the drop down list? I have tried using the lock propety but it does not let you select anything from the list or type anthing in.
Any takers?
Cheers
Geoff
-
Apr 13th, 2000, 09:36 PM
#2
Member
You need to handle the combo box's keypress and keydown events. You can then set the keyascii and keydown values to 0 and vbnull, respectively. Let me know if you need an example.
-
Apr 13th, 2000, 09:37 PM
#3
Or better yet, just change the Style property of the Combobox to 2 (Dropdown List).
-
Apr 13th, 2000, 09:40 PM
#4
Thread Starter
Addicted Member
Thanks
Just the ticket!
Geoff
-
Apr 14th, 2000, 12:29 AM
#5
Addicted Member
Some code examples would be nice on how to set it to null. I did a routine on keypress and there still is the possiblity of saving it with one character if you do it right; or is that wrong? by the user?
-
Apr 14th, 2000, 12:35 AM
#6
Sure. All you have to do is to set ListIndex property to -1.
Code:
Private Sub Combo1_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyDelete Then
Combo1.ListIndex = -1
End If
End Sub
Regards,
-
May 31st, 2000, 09:24 PM
#7
New Member
Combo
About how not to allow the user to input anything in a combobox
Private Sub cboBox_Change()
cboBox.Text = "" 'or whatever text
End Sub
-
May 31st, 2000, 11:23 PM
#8
No, use Combobox1_KeyPress and Combobox1_KeyUp events to do that:
Code:
Private Sub Combo1_KeyPress(KeyAscii As Integer)
KeyAscii = 0
End Sub
Private Sub Combo1_KeyUp(KeyCode As Integer, Shift As Integer)
KeyCode = 0
End Sub
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
|