|
-
Jul 2nd, 2000, 11:21 PM
#1
Thread Starter
Addicted Member
Hello,
I've got a form with a few combo boxes on it. The style of the boxes is set to "2 - Dropdown List"
in some other code i set the value of the comboboxes to something: eg
combo1.text = "hi there"
but when i do this it fires off the "click" event of the combo box (which does a whole heap of other processing that i don't want to do unless the user itself clicks the combo box - not when i change it programatically).
Is there a way to avoid the click event firing when the text of the combo box is set from within the code. I still want it to happen when the user actually clicks the combo.
Thanks - it's a bit important
if i'm not being clear then ask me - i'll explain better.
Mark
-
Jul 2nd, 2000, 11:33 PM
#2
Fanatic Member
Try this primitive approach until I find something more professional:
Code:
Option Explicit
Dim blClick As Boolean '//boolean used to determine if the
'//user click the combo or if the text changed with code
Private Sub Combo1_Click()
If blClick = False Then '//user chose to click the combo himself/herself
'//do whatever you want when the user clicks the combobox
MsgBox "Combo has been clicked"
End If
blClick = False '//reset the boolean
End Sub
Private Sub Command1_Click()
blClick = True '//text of the combo will be changed with code
Combo1.Text = "Welcomes" '//change the combo's text
End Sub
Private Sub Form_Load()
'//just to populate the combo
With Combo1
.AddItem "John"
.AddItem "Welcomes"
.AddItem "To"
.AddItem "VB"
.AddItem "World"
End With
End Sub
I hope you can follow what I did.
-
Jul 2nd, 2000, 11:43 PM
#3
Thread Starter
Addicted Member
Thanks QWERTY,
it may be that i have to take an approach like that - although it is not the nicest way (like you said).
i have discovered though if the combobox's style property is set to "0 - Dropdown Combo" the problem doesn't exist - ie the click event isn't fired - however if i use this style then the user can type whatever they want in the combobox which opens another can of worms.
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
|