473,385 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Why can't I get my ContextMenu to popup ?

I overrided a TreeView control and then overrided it's MouseClick event like
so:

protected override void OnMouseClick(MouseEventArgs e)
{
// base.OnMouseClick(e);
TreeNode node = this.GetNodeAt(e.Location);
this.SelectedNode = node;
if (e.Button == MouseButtons.Right)
{
Console.WriteLine("show menu");
blockMenu.Show(this, e.Location);
}
}

when I right click I see the text "show menu" in my console but the menu
never shows up - why?
Oct 27 '06 #1
1 1271
I figured out why...

In my constructor I created 3 ContextMenus. My plan was to have 3 separate
menus and in my mouse event I would simply toggle which one shows up
(setting the TreeView's ContextMenu in a switch)

I also thought I was going to be clever by creating onl yone instance of the
MenuItem objects and just simply add it to multiple menus if I wanted that
option in multiple menus

Turns out the ContextMenu "consume" the MenuItem so if I add it to one
context menu, and then add it to another after that, the second one stakes
his claim on it and the first one loses it!

It's really kind of bizarre behavior to me, but that's how it is!

it turned out the "blockMenu' I tried to show in my code was the one menu
that had only default menuitems that the other menus shared so it was
basically empty after the other 2 menus were loaded
Oct 27 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: JSjones | last post by:
when a form is submitted from the main window i want a pop up window to open from the onclick event. i have that working, now how can i close the pop up window from the main window after the main...
7
by: Jens Peter Hansen | last post by:
Hi From my main window I open a series of popup (one close - next opens) in a mockup for a registration proces. From the last popup, I want to click a buttom, so the popup closes and the URL in...
3
by: Bob | last post by:
I am trying to create a popup page (to act as a menu) from a parent page. When the parent page (index.jsp) calls my popup function (see below) it will properly open the correct size browser window...
1
by: Rob Petersen | last post by:
I have a datagrid with an Edit/Update column. Instead of editing records "in place" I'd like to do so in a separate popup window because there is a lot of validation, business rules and dynamic...
5
by: James Black | last post by:
In Firefox I can resize the window that is created, but in IE I can't. Here is the code I am using: var...
6
by: Ellie | last post by:
In my program the user clicks on a link and using the window.open function, opens a new window. I pass a url to the new window like this: <a href="#"...
3
by: =?Utf-8?B?Vk1J?= | last post by:
How can I close popup window automatically when I close the parent window (the application itself)? Thanks.
3
by: SamsonJohn | last post by:
HI ALL HOW CAN I CREATE POPUP APPEARS WITH TAIL POINTING TO PARENT WINDOW You can go through google calender When you click On theEvent a popup box APPEARS WITH TAIL POINTING TO PARENT WINDOW ...
0
by: Mahernoz | last post by:
Hi Friends, I simply want to print a report by opening a popup, calling the print function and closing the window after the user has printed the report. I have 2 functions.... in c# The...
1
mageswar005
by: mageswar005 | last post by:
hi, how to detect yahoo popup blocker, in my site i open a popup window but some local pc yahoo popup blocker can control my popup window. how can i detect the popup blocker....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.