Context Menu in Win Forms
May 12, 2008
Problem: How to add a context menu to a control and then add an event handler to it?
Solution:
ContextMenu refreshPopUp = new ContextMenu();
refreshPopUp.MenuItems.Add(“[context menu text]“, new EventHandler([method name]));
refreshPopUp.Show([control], new System.Drawing.Point(X, Y));
// Write the code for the event handler
private void methodName(object sender, EventArgs e)
{
do something;
}
Danish Khan
Entry Filed under: Win Form. .
Trackback this post | Subscribe to the comments via RSS Feed