context menus

C

Charles Crawford

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
 
W

Wei Lu [MSFT]

Hello Charles,

This issue appeared to be related with c# Winform. Please post this
question in the microsoft.public.dotnet.framework.windowsform newsgroup.
The microsoft.public.dotnet.framework.windowsform newsgroup is primarily
for issues involving windows form development using .NET. We recommend
posting appropriately so you will get the most qualified pool of
respondents, and so other partners who regularly read the newsgroups can
either share their knowledge or learn from your interaction with us.

Sincerely,

Wei Lu

Microsoft Online Community Support

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top