none
OnUpdate equivalent?

    Question

  • I come from the MFC world into c# and .net. In MFC I used OnUpdate commands (ON_UPDATE_COMMAND_UI) to handle enabling/disabling of menuitems, toolbarbuttons and other controls. From what I have seen there is no equivalent functionality in .net/c#?

    So, I have two questions:
    1 - Does Microsoft have a plan to implement this in upcoming versions of the framework?
    2 - Until then, what method is "best practise" for solving this in the world of .NET?

    regards Andreas

    Monday, December 25, 2006 9:14 AM

Answers

  • Dear Andreas,

    You should be reading this http://www.codeproject.com/cs/miscctrl/actionlist.asp 

    Taking the example of a menuitem, lets say you have programatically added a menuitem to a MainMenu mMenu :

    mMenu.MenuItems.Add(new MenuItem("Click",new EventHandler(Myhandler)));

    Now create a method as follows :

    private void MyHandler(object sender,System.EventArgs e)
    {

    this.Menu.MenuItems[0].Enabled = false;

    }

    For more information about handling events in C#, see
    Consuming Events.

    HTH,

    Suprotim Agarwal

     

     

    Monday, December 25, 2006 9:54 AM

All replies

  • Dear Andreas,

    You should be reading this http://www.codeproject.com/cs/miscctrl/actionlist.asp 

    Taking the example of a menuitem, lets say you have programatically added a menuitem to a MainMenu mMenu :

    mMenu.MenuItems.Add(new MenuItem("Click",new EventHandler(Myhandler)));

    Now create a method as follows :

    private void MyHandler(object sender,System.EventArgs e)
    {

    this.Menu.MenuItems[0].Enabled = false;

    }

    For more information about handling events in C#, see
    Consuming Events.

    HTH,

    Suprotim Agarwal

     

     

    Monday, December 25, 2006 9:54 AM
  • Ok, thanks, the actionlist will do fine.
    Not exactly as nice as the MFC solution, but it will do :-)

    Thank you!

    Thursday, December 28, 2006 9:27 AM