It is possible to attach a single context menu to different controls.
Here i 've a context menu , im trying to attach it with Form and a Button.
set the contextmenustrip property of Button and Form to contextmenustrip1
private void showToolStripMenuItem_Click(object sender, EventArgs e)
{
Control c = contextMenuStrip1.SourceControl;
if (c is Button)
MessageBox.Show("Invoked By Button");
else if(c is Form)
MessageBox.Show("Invoked By Form");
}
0 comments:
Post a Comment