context menus
- From: "Charles Crawford" <echuck66@xxxxxxxxxxxxxxxx>
- Date: Mon, 21 Aug 2006 18:46:06 -0400
Hello,
I'm writing a windows forms application and have a custom user control built
from multiple controls, including a picturebox control onto which I'm
drawing a clock face. Each hour on the clock face represents a 'node' and I
have the application switch cursors from the arrow to hand cursors each time
the mouse moves over one of the nodes.
I have a contextmenustrip control assigned to the picturebox control, but I
only wish to display the context menu when the mouse is over one of the
nodes.
I've tried to use the mousedown event on the picturebox as follows:
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right && pictureBox1.Cursor ==
Cursors.Hand)
{
pictureBox1.Cursor = Cursors.Arrow;
contextMenuStrip1.Visible = true;
}
else
{
contextMenuStrip1.Visible = false;
}
}
The problem I'm having is that the context menu shows up whenever I
right-click on the picturebox, regardless of whether it's over a 'node' or
not.
Thanks in advance.
Charlie
.
- Follow-Ups:
- RE: context menus
- From: Wei Lu [MSFT]
- RE: context menus
- Prev by Date: Find control on a form
- Next by Date: Re: Unable to open forms or reports
- Previous by thread: Find control on a form
- Next by thread: RE: context menus
- Index(es):