Dynamic ContextMenuStrip
In my application I have 3 RichTextboxes, I created only one
ContextMenuStrip because I don't like the idea of duplicate the same code
of the same contextmenu and all the context menu options 3 times to use it
with the other 2 Richs, the problem is I don't know how to use the same
ContextMenu for the three RichTextBoxes.
For example one option of the ContextMenuStrip is "Clear text", then
inside the procedure I need to specify the RichTextbox object name to
clear the text:
Private Sub MenuItem_Clear_Text_Click(sender As Object, e As EventArgs) _
Handles MenuItem_Clear_Text.Click
RichTextBox_Affix.Clear()
End Sub
How I can handle in a dynamic way the clear method in that sub for the
other richtextboxes?
I've tried to find the necessary information about which RichTextBox
called the contextmenu to handle the contextmenu procedure only for that
RichTextBox, but I've found anything in the sender or "e" variables.
No comments:
Post a Comment