.NET Framework - Initial Position of Contextmenu
Asked By unk
25-Jan-07 04:06 AM
Hi,
In the documentation I read that a ContextMenu appears at the mouse position
when the user clicks the right mouse button. So far so good. In my situation,
however the menu pops-up at a random position, and when I release the mouse
button it get's positioned at the correct place.
I have no clue why ... can anyone give me a hint?
To show the control I use the following statement;
MyContextMenuStrip.Show(mousePoint)
--
It''s Software Jim, but not as we know it!
ContextMenuStrip
(1)
MyContextMenuStrip
(1)
MousePoint
(1)
MouseEventArgs
(1)
MouseDown
(1)
PointToScreen
(1)
MouseButtons
(1)
_MouseClick
(1)
v-lli replied...

Hi,
I performed a test based on your description but couldn't reproduce your
problem.
I create a WinForm application project and add a ContextMenuStrip on the
form. I handle the Form's MouseClick event and in the event handler, I add
the following code.
void Form1_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
this.contextMenuStrip1.Show(this.PointToScreen(e.Location));
}
}
Build the project and run it. When I click the right mouse button on the
form, no context menu strip appears. Only after I release the right mouse
button, the context menu strip pops up at the correct position. All works
fine.
Could you tell me in which event handler you call the statement
'MyContextMenuStrip.Show(mousePoint)'?
Sincerely,
Linda Liu
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.
unk replied...
Hi Linda,
I am using VB but your example runs fine at my computer too. Although I am
using the MouseDown event, the result is what one would expect. So there must
be something else that is causing the behaviour.
It probably has to do with the control I am using (an Infrasgistics grid
control). I am setting the control's ContextMenuStrip attribute to the
correct strip, and then catch the MouseDown event for the control.
I'll setup a small test app and see when and where things go wrong
--
It''s Software Jim, but not as we know it!
unk replied...
Hi,
I can confirm it is an issue with the control on the form. Infragistics is
now working on it.
Apologies, should have tried a simple example first, like you suggest,
before putting it up here.
TnX for your help Linda
--
It''s Software Jim, but not as we know it!
v-lli replied...
Hi,
No problem. You're welcome!
If you have any other questions in the future, please don't hesitate to
contact us. It's always our pleasure to be of assistance!
Sincerely,
Linda Liu
Microsoft Online Community Support
ich habe ein DataGridView mit einem Kontextmen? erstellt. private void Form1_Load(object sender, EventArgs e) { ContextMenuStrip contextMenuStrip = new ContextMenuStrip(); contextMenuStrip.Items.Add("Mache"); dataGridView1.ContextMenuStrip = contextMenuStrip; } Mit einem Button will ich das Kontextmen? unsichtbar setzen. private void button1_Click(object sender, EventArgs e) { dataGridView1.ContextMenuStrip.Visible = false; } Das funktioniert aber nicht! Deaktivieren funktioniert : dataGridView1 ContextMenuStrip.Enabled = false; Was mache ich falsch mit .Visible = false;, oder welchen Sinn hat es? Wie
ContextMenuStrip with a ContextMenuStrip Child .NET Framework i have a menu system that is generated dynamically everything works good except for one minor astetic. . . . I click on a menu item that displays a ContextMenuStrip Popup Menu If an item on that ContextMenuStrip calls another ContextMenuStrip, i want the original ContextMenuStrip to stay visible until a choice is made on the second ContextMenuStrip. vb 2005 .net 2.0 suggestions? VB.NET Discussions Popup (1) more simply. . . . if i click on an item in a ContextMenuStrip, how do i keep the ContextMenu from going away until i want it to? keywords
ContextMenuStrip .NET Framework Hola, estoy usando visual basic 2008, tengo 5 picturebox, y a cada de uno le asocio un mismo contextmenustrip. Como hago para saber de que picturebox estoy llamando al contextmenustrip???. Saber de que picturebox active el contextmenustrip. Les agradercia sus comentarios. VB.NET - Spanish Discussions System.Windows.Forms ContextMenuStrip (1) System.ComponentModel.CancelEventArgs (1) System.Windows.Forms.Control (1) CancelEventArgs (1) System.EventArgs (1 e As System.ComponentModel.CancelEventArgs) Handles ContextMenuStrip1.Opening temporal = (DirectCast(DirectCast(sender, System.Windows.Forms.ContextMenuStrip).SourceControl, System.Windows.Forms.Control).Name) End Sub Private Sub menuOpcion1_Click(ByVal sender As System Debug.WriteLine("Opcion #1 sobre el control llamado:" + temporal) End Sub Gracias funciono correctamente!!! keywords: ContextMenuStrip description: Hola, estoy usando visual basic 2008, tengo 5 picturebox, y a cada de uno le asocio un mismo contextmenustrip. Como hago para saber de que picturebox esto
ContextMenuStrip steals focus? .NET Framework Hello All, I have a small problem. I have a RichTextBox, which calls a ContextMenuStrip, when a user types certain text. The problem I am faced with is that I cannot return the focus (keyboard input, etc.) to the RichTextBox, once the ContextMenuStrip opens. When the ContextMenuStrip opens, I'd like the keyboard input to continue for the RichTextBox. Does anyone know to accomplish this task? Thanks, Ryan C# Discussions Visual Studio (1) RichTextBox (1) VB (1) ContextMenuStrip (1) MessageOK (1) Saver.Regards (1) Dorset (1) Gates (1) That might make it a You know how everyone likes Intellisense? Same idea here. Intellisense is nothing more than a ContextMenuStrip (or something akin to it), which pops up when you are typing in a text application I am developing. You can continue typing in the text editor even when the ContextMenuStrip is open. Perhaps I am misusing the word focus here, but I believe I have much. You are a life saver. Regards, Ryan Thank You for your assistance. -Ryan keywords: ContextMenuStrip, steals, focus? description: Hello All, I have a small problem. I have a RichTextBox, which