K
Kenneth Baltrinic
I have an custom owner drawn control that when clicked on needs to pop up a
list of options. I want to use a popup menu (ContextMenu) for this. My
code runs fine but no menu ever appears. I commented out my original
OnClick routine and put the following in to simplify the test and still
nothing happend. Placing a break point confirms, the code is runinng and no
exceptions are being thrown. Just no menu ever appears.
Here is some more data reveals by my testing:
This control is on a form that is being displayed with the ShowDialog()
method. If this method is invoked from within the Click event handler of a
prior context menu, the problematic behavoir is seen. If I call ShowDialog()
through some other means. (Clicking on button for example) then the below
code works just fine and the context menu appears.
--Ken
protected override void OnClick(EventArgs e)
{
base.OnClick (e);
ContextMenu MyList = new ContextMenu();
MenuItem mi1 = new MenuItem("Test Item 1");
MenuItem mi2 = new MenuItem("Test Item 2");
MyList.MenuItems.Add(mi1);
MyList.MenuItems.Add(mi2);
MyList.Show(this, Point.Empty);
}
list of options. I want to use a popup menu (ContextMenu) for this. My
code runs fine but no menu ever appears. I commented out my original
OnClick routine and put the following in to simplify the test and still
nothing happend. Placing a break point confirms, the code is runinng and no
exceptions are being thrown. Just no menu ever appears.
Here is some more data reveals by my testing:
This control is on a form that is being displayed with the ShowDialog()
method. If this method is invoked from within the Click event handler of a
prior context menu, the problematic behavoir is seen. If I call ShowDialog()
through some other means. (Clicking on button for example) then the below
code works just fine and the context menu appears.
--Ken
protected override void OnClick(EventArgs e)
{
base.OnClick (e);
ContextMenu MyList = new ContextMenu();
MenuItem mi1 = new MenuItem("Test Item 1");
MenuItem mi2 = new MenuItem("Test Item 2");
MyList.MenuItems.Add(mi1);
MyList.MenuItems.Add(mi2);
MyList.Show(this, Point.Empty);
}