By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,671 Members | 1,567 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,671 IT Pros & Developers. It's quick & easy.

Attach ContextMenu to control

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.