Hi!
I have added a contextmenustrip on my form and in the contextmenustrip I have added two items. when I click on the 1st contextmenustrip item it works but when I click on the 2nd contextmenustrip item it does not work only the 1st contextmenustrip item works.
and when I debug the program again and click on the 2nd contextmenustrip item it works but when I click on the 1st contextmenustrip item it does not work only the 2nd contextmenustrip item works.
what is the solution?

Please reply soon!

1st item calls keypressevent
2nd item calls another keypressevent.
*they are in different subs.
Like i.keypress and k.keypress

I understand.
But what i wanted to know is, how to add two controls in two cms item.
Suppose cms 1st item shows a form and 2nd cms item shows a form too. And i have clicked 1st item and the form is shown But when i click on 2nd item how to hide the 1st form and show 2nd form and vice-versa.
Sorry for my bad english.

"But when i click on 2nd item how to hide the 1st form and show 2nd form and vice-versa."

That's not what you asked up top. Next time, ask what you really want to ask.

Just an idea as we have no code to look at here.

On either handler, add some formname.hide to hide the other form.

Did you really read my reply i wrote "suppose". And i have written it because i am unable to give the code. It's 1:00 pm in our country and it's time to go to bed.
If you can then please reply. Try to understand man.....

I'll have a better understanding looking at the code and the issue. As to your suppose, I offered an idea and the method to hide the other form. But I can't write the code for you as there is no code to read and suggest "put this there."

Here is the code:

Private Sub ido_KeyPress(ByVal sender As Object, ByVal e As KeyPressEventArgs) Handles ido.KeyPress

    If e.KeyChar = ("a") Then
        e.Handled = True
        SendKeys.Send("x")
    End If

    Private Sub Mydo_KeyPress(ByVal sender As Object, ByVal e As KeyPressEventArgs) Handles mydo.KeyPress

    If e.KeyChar = ("a") Then
        e.Handled = True
        SendKeys.Send("n")
    End If

    Private Sub MapToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles MapToolStripMenuItem.Click

    If ContextMenu1.SourceControl Is ido Then
        Mydo.Startwork()
    End If



End Sub

Private Sub Map2ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles Map2ToolStripMenuItem.Click

    If ContextMenu1.SourceControl Is Mydo Then
        ido.Startwork()
    End If

That's not the section of code that shows a form or other screen object. I see some undefined MyDo.Startwork() and another but I don't know what that is.

However and again, if you need to hide a form, use the objects .hide method. Since I don't see the code maybe after line 25
Mydo.Hide

MyDo.Startwork() Hooks the keyboard

I can't know that. Have you heard the story of 3 blind men and an elephant. Same thing here.

-> Again. If you need some other form to hide when you show your new form, use the .hide before you show your new form.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.