Accessing RadMenuItem in MDI Child Form with Alt Key

8 posts, 0 answers
  1. Meaning Of Lights
    Meaning Of Lights avatar
    24 posts
    Member since:
    Dec 2007

    Posted 22 Jan 2014 Link to this post

    Hi,

    I have a MDI Winform application that has menus on the parent form and also on the child forms.

    The Child Form has menus such as: &File, &Edit and I would like these child form menu's to get focus when users press eg:

    Alt + F or Alt + E

    Unfortunately pressing the Alt key always gives focus to the Parent Form menu's.

    How can I make the Alt key give focus to the Active Child Forms menu?
  2. George
    Admin
    George avatar
    500 posts

    Posted 27 Jan 2014 Link to this post

    Hello Jeremy,

    Thank you for contacting us.

    I can confirm this issue, I have added it to our Feedback Portal. You can find it on the following url: FIX. RadMenu - When RadMenu is added to a MDI child Form only the main RadMenu is accessible through shortcuts with Alt Key.

    As a workaround you can subscribe to the KeyUp event of every child form and click the menu items manually:
    private void childForm_KeyUp(object sender, KeyEventArgs e)
    {
        Form form = sender as Form;
        if (!form.Focused)
        {
            return;
        }
     
        RadMenu menu = null;
        foreach (Control control in form.Controls)
        {
            if (control is RadMenu)
            {
                menu = control as RadMenu;
                break;
            }
        }
     
        if ((Control.ModifierKeys & Keys.Alt) == Keys.Alt && menu != null)
        {
            foreach (RadItem item in menu.Items)
            {
                int ampersantIndex = item.Text.IndexOf("&");
                if (ampersantIndex != -1)
                {
                    char hotkeyChar = item.Text[ampersantIndex + 1];
                    if (char.ToLower(hotkeyChar) == char.ToLower((char)e.KeyValue))
                    {
                        item.PerformClick();
                        break;
                    }
                }
            }
        }
    }

    I have also updated your Telerik Points for reporting this.

    I hope this helps.

    Regards,
    George
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. n/a
    n/a avatar
    34 posts
    Member since:
    Jan 2018

    Posted 03 Jan in reply to George Link to this post

    Hello George,

    I've checked with the code you have shared, but When I click Alt button, it is getting focused on the MDI parent form.
    Then when I click the Alt button for the second time, the event is getting called in the MDI child form and returns that the child form is not in focus. Please refer  image 1

    What I expect from this is when the child form is open, once I click the Alt button it should directly focus on the child form menu bar. Please refer image 2


  4. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3369 posts

    Posted 07 Jan Link to this post

    Hello, Rick,  

    Note that RadMenu automatically discovers that it is placed in a child MDI form. When a child MDI form is maximized, RadMenu automatically merges the Menu items in the parent form. Thus, you can easily activate the respective menu item from the child form by pressing the Alt key and the respective shortcut letter. Additional information is available in the following help article: https://docs.telerik.com/devtools/winforms/controls/menus/menu/menu-merge/menu-merge-in-mdi-applications

    I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  5. n/a
    n/a avatar
    34 posts
    Member since:
    Jan 2018

    Posted 18 Jan in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Hello, Dess,

    Thank you, But I'm setting a property of (AllowMerge= false) in MDI parent form & when the child form is open (in window state (maximized/ Normal)). When I click the Alt button it should directly focus on the child form menu bar.
    Note: I don’t need child & parent form to be merged & it should be separate & focus should be present in it.

  6. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3369 posts

    Posted 22 Jan Link to this post

    Hello, Rick,      
      
    If you prefer not to merge the menus of the child and parent MDI forms, it would be necessary to show the drop down items programmatically as it is demonstrated below. However, have in mind that the parent menu is focused by design which behavior is also available with the standard MS Form: 

    public ParentForm()
    {
        InitializeComponent();
        this.IsMdiContainer = true;
     
        this.radMenu1.AllowMerge = false;
     
        ChildForm f = new ChildForm();
        f.KeyUp += f_KeyUp;
        f.MdiParent = this;
        f.Show();
    }
     
    private void f_KeyUp(object sender, KeyEventArgs e)
    {
        Form form = sender as Form;
        if (!form.Focused)
        {
            return;
        }
     
        RadMenu menu = null;
        foreach (Control control in form.Controls)
        {
            if (control is RadMenu)
            {
                menu = control as RadMenu;
                break;
            }
        }
     
        if ((Control.ModifierKeys & Keys.Alt) == Keys.Alt && menu != null)
        {
            foreach (RadItem item in menu.Items)
            {
                int ampersantIndex = item.Text.IndexOf("&");
                if (ampersantIndex != -1)
                {
                    char hotkeyChar = item.Text[ampersantIndex + 1];
                    if (char.ToLower(hotkeyChar) == char.ToLower((char)e.KeyValue))
                    {
                        ((RadMenuItem)item).ShowChildItems(); 
                        break;
                    }
                }
            }
        }
    }

    P.S. Note that the standard MS Form and Menu are always merged at the parent form and you can't obtain a situation of having two separate menus on the two MDI forms.
      
    I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  7. n/a
    n/a avatar
    34 posts
    Member since:
    Jan 2018

    Posted 29 Jan in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Hello, Dess,

    The provided code is not helping us with fixing this issue. When I click Alt button, it is getting focused on the MDI parent form.
    Then when I click the Alt button for the second time, the keyup event is getting called in the MDI child form and returns that the child form is not in focus. Video link mentioned below for your reference.

    Video link:     https://tamilarasan-gmail.tinytake.com/sf/MzI2NjUwN185NzgzODM2

    What I expect from this is when the child form is open, once I click the Alt button it should directly focus on the child form menu bar. Please help us with codes or any projects if any.

  8. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3369 posts

    Posted 30 Jan Link to this post

    Hello, Rick,       

    The provided sample video is greatly appreciated. After further investigating the menu behavior in a MDI scenario, I confirm that the MDI child form doesn't handle properly the Alt key. 

    I have logged it in our feedback portal by creating a public thread on your behalf. You can track its progress, subscribe for status changes and add your comments on the following link - feedback item.

    Feel free to continue the communication there. Thank you for your cooperation and understanding.

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top