473,396 Members | 2,036 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,396 software developers and data experts.

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 2097
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.Threading.Timer)
......
TimerCallback timerCallback = new TimerCallback(someFunction);
tmr = new Timer(timerCallback, null, 0, 5000);
......

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

public static void someFunction(object status) {
if (someEvent != null) {
someEvent(null, new SomeEventArgs(m_someParam));
}
}

Some Forms gets this event:
.......
someEvent += new SomeEventHandler(form_someEvent);
.......

And in Dispose:
.......
someEvent -= new SomeEventHandler(form_someEvent);
.......
When user click on menuItem in ContextMenu i open dialog -
.......
someDialog.ShowDialog();
.......

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
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...
2
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...
0
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...
4
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...
11
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...
0
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...
7
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...
13
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...
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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,...

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.