Control.ControlForm.Menu

  • Thread starter Thread starter Roman S. Golubin1709176985
  • Start date Start date
R

Roman S. Golubin1709176985

Hi, everybody!

I create a control inherited from System.Windows.Forms.Control and override
OnParentChanged method:

public class MyControl : System.Windows.Forms.Control
{
protected override void OnParentChanged(System.EventArgs e)

{

// I look for current parent form

System.Windows.Forms.Form frm = this.FindForm();

// and I want to change the parent form Menu:

frm.Menu.Add(...);



and have a problem: creation sequence from the parent form create MyControl
before assign Menu to actual form Menu.

Say please can I monitoring Form.Menu assign ?



Thanks avanced.

--

WBR, Roman S. Golubin



PS: Sorry for bad english.
 
I said:
Say please can I monitoring Form.Menu assign ?

I see as solution for this problem inheritance System.Windows.Forms.Form to
myself MyFormClass, override property Menu and inherite all my forms from it
and this method don't well for me ;-((

I use dotnetframework v1.0.3705 at this time and don't sure that migration
to 1.1.4322 solve this problem??

Does anyone say why Microsoft add ContextMenuChanged event to Control class
and don't add MenuChanged event to Form??

-- code for MyForm inherited from ****invalid**** System.Windows.Forms.Form
: --

public class Form : System.Windows.Forms.Form
{
public event EventHandler MenuChanged;
public new System.Windows.Forms.MainMenu Menu
{
get
{
return base.Menu;
}
set
{
base.Menu = value;
if (MenuChanged != null)
{
MenuChanged(this, EventArgs.Empty);
}
}
}
}
 
Back
Top