Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Two textbox and one contextmenu

Status
Not open for further replies.

ASMA

Technical User
Sep 23, 2000
12
0
0
ES
Hi everybody

I have several textboxes with one context menu.

How can I know the textbox where the mouse clicked to raise the menu and pass it to the "MenuItem1.Click"

Thanks in advance.
 
The textbox itself has a clicked event. You can use this to pass whatever information you want.

DotNetDoc
M.C.S.D.
---------------------------------------

Tell me and I forget. Show me and I remember. Involve me and I understand.
- Anonymous Chinese Proverb
-----------------------------------
If you can't explain it simply, you don't understand it well enough.
- A. Einstein
 
HI ASMA
yes dotnotdoc is right you can do easily whatever you want in Textbox1_MouseDown or Textbox1_MouseUp event but you might want something different..so here is the logic for you case
Regards
Nouman

Dim myTextbox as TextBox
Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click
'which text box
If Not myTextbox Is Nothing Then
Select Case myTextbox.Name
Case Is = "TextBox1"
MsgBox("Textbox1 is clicked")
Case Is = "TextBox2"
MsgBox("Textbox2 is clicked")
End Select
End If

End Sub

Private Sub TextBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseDown
If e.Button.Equals(MouseButtons.Right) Then
myTextbox = sender
End If
End Sub

Private Sub TextBox2_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox2.MouseDown
If e.Button.Equals(MouseButtons.Right) Then
myTextbox = sender
End If
End Sub

Nouman Zaheer
Software Engineer
MSR
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top