I have used 2 combo box ,how can i enable 1st combobox when i click on 2nd combobox viceversa .if i am entering a data in 1 of the combobox then another should be disable ,but after entering data in the any 1 of combobox ,again clicking on the another combobox to enable it and disabling the entered data combobox.
can i get some hlp .

I would suggest the KeyPress and GotFocus functions. If one gets focus, the other is disabled. Then, if a specific key is pressed (enter or esc), the other is again enabled.

I'm thinking why you want something like that.
If you work with combobox1.enabled in the gotfocus event of combobox2,
than the combobox1 hasn't got a focus anyway. And viceversa.
Default by clicking on a control it gets the focus.
So how could a user change the other combobox?
What is the plus of disabling the other combobox?
And as soon as the user clicks combobox1, the gotfocus event of that combo fires.
So enabling in gotfocus will bring you nothing, will it?

hi,

Use the keypress Event for your requirement because while any control is disabled then the control events does not fire so Keypress event is best one.

See below i given the coding:

Private Sub Combo1_KeyPress(KeyAscii As Integer)
Combo2.Enabled = False
If KeyAscii = 9 Then
Combo2.Enabled = True
Combo1.Enabled = False
End If
End Sub

Private Sub Combo2_KeyPress(KeyAscii As Integer)
Combo1.Enabled = False
If KeyAscii = 9 Then
Combo1.Enabled = True
Combo2.Enabled = False
End If
End Sub

Al the best.
shailu

hi,


:cool: if u like to know the keyascii values for the keys press f2 key for object browser then type keycodeconstant. u will get all keyascii values.

:cool:

best regards
shailu

ManoShoilu's approach is fine.But what is all this enabling and disabling all about??
if it's practise then fine,tell us what you want to achieve???

I have used 2 combo box ,how can i enable 1st combobox when i click on 2nd combobox viceversa .if i am entering a data in 1 of the combobox then another should be disable ,but after entering data in the any 1 of combobox ,again clicking on the another combobox to enable it and disabling the entered data combobox.
can i get some hlp .

Maybe you should tried it first before posting your problem here. Haven't you tried to look for a tutorial? here try this one if you have no MSDN in your computer http://www.vbtutor.net/vbtutor.html

It is a question of a combobox that is to be activated (Fiiled with data, perhaps, according to the selection done in the other combo and vice versa.)

Let jatinder explain it some more.


happy programming
regards
AV Manoharan.

hi,


:cool: if u like to know the keyascii values for the keys press f2 key for object browser then type keycodeconstant. u will get all keyascii values.

:cool:

best regards
shailu

Hi!
shailu...
I read your patience code... and hopefully I appreciate it ^_^. actually I would like to be your friend. heheh..Your to good in VB and i need u in my study..can you be my friend???
just email me at asaria_ja@yahoo.com
thx...

This article has been dead for over six months. Start a new discussion instead.