May 28th, 2007, 10:50 AM
[RESOLVED]  Contextmenustrip - One function to rule them all
This is my first post and i'm quite new to VB2005 so hopefully i'll explain what i'm after properly.
Basically i'm creating a single contextmenu for each of the text boxes I have on a form. Most of the contextmenu will be populated with text which when the user selects it, is set in the textbox which used the contextmenu.
Now I can do the contextmenu, thats fine and populate it with the data, the problem i'm having is telling the textbox to display the text the user has selected on the contextmenu.
I'm using sourcecontrol to find out which textbox fired the contextmenu but once one of the items is selected nothing is displayed in the textbox. I have also tried it with a msgbox to try and see whats going on but nothing is displayed in that also.
Here's a quick sample to show what i'm trying to do:
What I would eventually like to do is write just one function which finds which textbox fired the contextmenu and then set its text to that of the chosen menuitem on the contetmenu.
Private Sub ContextMenuStrip_click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ContextMenuStrip.Click
If ContextMenuStrip.SourceControl Is TextBox1 Then
TextBox1.Text = ContextMenuStrip.Text
ElseIf ContextMenuStrip.SourceControl Is TextBox2 Then
TextBox2.Text = ContextMenuStrip.Text
I really appreciate any help someone can give me.
Last edited by madcat1981; May 29th, 2007 at 12:06 PM.
Click Here to Expand Forum to Full Width