Posts filed under 'Win Form'

Context Menu in Win Forms

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

Ramp Technology

Add comment May 12, 2008


Calendar

November 2009
M T W T F S S
« Jul    
 1
2345678
9101112131415
16171819202122
23242526272829
30  

Posts by Month

Posts by Category