Control.ControlForm.Menu

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Roman S. Golubin1709176985

    #1

    Control.ControlForm.Menu

    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.EventAr gs 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.




  • Roman S. Golubin1709176985

    #2
    Re: Control.Control Form.Menu

    I wrote:
    [color=blue]
    >
    > Say please can I monitoring Form.Menu assign ?
    >[/color]

    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 ContextMenuChan ged 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(thi s, EventArgs.Empty );
    }
    }
    }
    }

    --
    Thanks a lot for any help
    Roman S. Golubin


    Comment

    Working...