I have an Windows Form app with multiple Textboxes. I'm trying to add a right-click copy & paste function into it. I have added the right-click menu by using the ContextMenuStrip. However, I'm using this menu for 2 different textboxes in the app. When I select and highlight some text from 1 text box and then do the same thing by selecting and highlighting text from the other textbox, it copies in the text from both textboxes. How do I separate it so that it knows which textbox to copy from?
This is the code I have:
private void copyToolStripMenuItem_Click(object sender, EventArgs e)
{
string leadSelectedText = leadsTextBox.SelectedText;
string resultSelectedText = resultTextBox.SelectedText;
Console.WriteLine(leadSelectedText);
Console.WriteLine(resultSelectedText);
}