This is a migrated thread and some comments may be shown as answers.

Accessing RadMenuItem in MDI Child Form with Alt Key

7 Answers 105 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Meaning Of Lights
Top achievements
Rank 2
Meaning Of Lights asked on 23 Jan 2014, 05:03 AM
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?

7 Answers, 1 is accepted

Sort by
0
George
Telerik team
answered on 27 Jan 2014, 11:48 AM
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 >>
0
Dev
Top achievements
Rank 1
Veteran
answered on 03 Jan 2019, 10:01 AM

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


0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 07 Jan 2019, 07:48 AM
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.
0
Dev
Top achievements
Rank 1
Veteran
answered on 18 Jan 2019, 11:42 AM

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.

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 22 Jan 2019, 09:15 AM
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.
0
Dev
Top achievements
Rank 1
Veteran
answered on 29 Jan 2019, 11:21 AM

Hello, Dess,

The provided code is not helping us with fixing this issue. When I click 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. 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.

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 30 Jan 2019, 09:42 AM
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.
Tags
Menu
Asked by
Meaning Of Lights
Top achievements
Rank 2
Answers by
George
Telerik team
Dev
Top achievements
Rank 1
Veteran
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or