473,804 Members | 2,195 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Attach ContextMenu to control

Hello!

I have such problem!

I have my UserControl. I override property ContextMenu for this
Control as

.....
new ContextMenu ContextMenu{
set {_contextMenu = value;}
get {return _contextMenu;}
}

.....

This code works. But if i open new Window using this context menu (for
example New Dialog) and send event to this Dialog my dialog dont get
event and after closing this form my application hangs.

I knew, that problem is in ContextMenu (specially in set_ContextMenu ),
but i dont understand what is wrong.

Please, help!!!!

Best Regards, Vladimir.
Nov 16 '05 #1
2 2127
You showed us the code that works but not the code that doesn't work. Can
you provide a sample of how you're calling the dialog, what events you're
"sending" and how, and how you're closing your dialog.

To make it easier to duplicate your problem, strip out any unneeded code and
test what you send us to make sure it still demonstrates the symptoms you're
describing.

DalePres
MCAD, MCDBA, MCSE
"Zieben" wrote:
Hello!

I have such problem!

I have my UserControl. I override property ContextMenu for this
Control as

.....
new ContextMenu ContextMenu{
set {_contextMenu = value;}
get {return _contextMenu;}
}

.....

This code works. But if i open new Window using this context menu (for
example New Dialog) and send event to this Dialog my dialog dont get
event and after closing this form my application hangs.

I knew, that problem is in ContextMenu (specially in set_ContextMenu ),
but i dont understand what is wrong.

Please, help!!!!

Best Regards, Vladimir.

Nov 16 '05 #2
Hello!

OK.
It is very easy.
I have timer (System.Threadi ng.Timer)
......
TimerCallback timerCallback = new TimerCallback(s omeFunction);
tmr = new Timer(timerCall back, null, 0, 5000);
......

public delegate void SomeEventHandle r(object sender, someEventArgs e);
public static event SomeEventHandle r someEvent;

public static void someFunction(ob ject status) {
if (someEvent != null) {
someEvent(null, new SomeEventArgs(m _someParam));
}
}

Some Forms gets this event:
.......
someEvent += new SomeEventHandle r(form_someEven t);
.......

And in Dispose:
.......
someEvent -= new SomeEventHandle r(form_someEven t);
.......
When user click on menuItem in ContextMenu i open dialog -
.......
someDialog.Show Dialog();
.......

and when user click 'OK' or 'Cancel' button on dialog i write
.......
DialogResult = DialogResult.OK ;
Close();
.......
That is my code. If i comment generating event everything is ok. But
if event generates - everything crashed. I`ve tryed make it with
standart Control, like ListView, and everything was fine. - So i think
that trouble is in attaching of ContextMenu to my Control.

Best Regards, Vladimir.
You showed us the code that works but not the code that doesn't work. Can
you provide a sample of how you're calling the dialog, what events you're
"sending" and how, and how you're closing your dialog.

To make it easier to duplicate your problem, strip out any unneeded code and
test what you send us to make sure it still demonstrates the symptoms you're
describing.

DalePres
MCAD, MCDBA, MCSE
"Zieben" wrote:
Hello!

I have such problem!

I have my UserControl. I override property ContextMenu for this
Control as

.....
new ContextMenu ContextMenu{
set {_contextMenu = value;}
get {return _contextMenu;}
}

.....

This code works. But if i open new Window using this context menu (for
example New Dialog) and send event to this Dialog my dialog dont get
event and after closing this form my application hangs.

I knew, that problem is in ContextMenu (specially in set_ContextMenu ),
but i dont understand what is wrong.

Please, help!!!!

Best Regards, Vladimir.

Nov 16 '05 #3

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

Similar topics

0
1667
by: MD | last post by:
I have a ContextMenu that is assigned to 3 RichTextBox's (i.e., if you right-click on any of the 3 RichTextBox's, you get the same ContextMenu). My ContextMenu has 2 items, each of which have their own click event handlers. When I click on any of the options in the ContextMenu, I want to know which RichTextBox the ContextMenu is currently opened in, so I thought I could check the SourceControl property. The problem is, the property is...
2
1820
by: Ryan Joseph So | last post by:
Is it possible to disable the paste contextmenu of a control without creating a new contextmenu to handle this, so i wont be able use to paste on that control. Ryan. *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
0
1022
by: Jorge | last post by:
Hello I am trying to browse a form and i know it has 3 contextmenus and a mainmenu. Public Sub PercorreMenus(ByVal f As Form) Dim ctl As Control For Each ctl In f.Controls If ctl.Controls.Count > 0 Then PercorreMenus2(ctl, f) End If
4
3374
by: Frank Rizzo | last post by:
Hello, I have a listview control with bunch of entries. When the user right-clicks on the item, I want a context menu to come up. So I created a ContextMenu instance and assigned it to ListView.ContextMenu property. The problem is that the context menu comes up regardless of whether I right-click on the item or the empty space or the column header. I want it only to come up when the user right-clicks on an item. How can I
11
2681
by: Graham Charles | last post by:
I'm writing a control inheriting from ComboBox, and I'd like to add an entry to the ContextMenu for that combo box. I have no problem if I create an entirely new ContextMenu from scratch, but I'd prefer just to tack my MenuItem on to the existing, built-in ContextMenu (Cut, Copy, Paste, etc.): _RemoveMRUItemMenu = New MenuItem _RemoveMRUItemMenu.Text = "&Remove Item" _RemoveMRUItemMenu.Enabled = False
0
1464
by: Ahmad Jalil Qarshi | last post by:
Hi! I have a NotifyIcon and a ContextMenu attached to it. What I want is to show the ContextMenu when the mouse pointer is over the NotifyIcon and hide the contextMenu when the Mouse pointer moves away from the NotifyIcon. To show it when the mouse pointer is over the NotifyIcon I have written following code in the OnMouseMove event.
7
2234
by: wandii | last post by:
Hi, I am trying to show the shortcut menu on a richtextbox control by adding the contextmenu component onto the form. The richtextbox property is assigned to the contextmenu. I created my shorcuts, copy, paste, etc. However, on the form I have a datagrid which is also assigned to the same contextmenu and contextmenupopup event as follows: .... If ContextMenu1.SourceControl Is richtextbox1Then ' Add MenuItems to display for the TextBox.
13
2465
by: pamelafluente | last post by:
Hello. I have written the following code (this code is on a control): Sub InitSomething() mSet(me.FindForm) End Sub Sub mSet(ByVal f As Control) For Each t As Control In f.Controls If TypeOf t Is ToolStripMenuItem Then AddHandler t.MouseEnter, AddressOf Me.SetSemaforoMenu
1
6734
by: Darin | last post by:
I understand microsoft's change from contextmenu to contextmenustrip - the strip looks "prettier". But, since the contextmenu isn't available in the designer, it suer woul dhave been nice when updating a project from VS2003 to VS2005 that it asked if you wanted to change all of the menus. I now have hundreds (if not thousands) of menus that need to be changed from contextmenu to contextmenustrip. Is there an option/program somewhere...
0
9715
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9595
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10354
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9175
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6867
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5535
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3835
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3002
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.