Menu with Panel of buttons or User Control hosted in Menu

2 posts, 0 answers
  1. Jeremy
    Jeremy avatar
    1 posts
    Member since:
    Jul 2013

    Posted 11 Nov 2013 Link to this post

    Hi,

    I am wanting to know if its possible to make a Menu Item contain a grid of buttons such as the Labels TextAlign PropertyGrid menu in Visual Studio as per attached pic? 

    Or is it possible to put a User Control in a Menu Item?

    Thanks.
  2. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 14 Nov 2013 Link to this post

    Hello Jeremy,

    Thank you for contacting Telerik Support.

    The recommended approach is to use a custom RadMenuItem which you can build with the desired elements. Here is a simple example:
    public class CustomMenuItem : RadMenuItem
    {
        protected override Type ThemeEffectiveType
        {
            get
            {
                return typeof(RadMenuItem);
            }
        }
     
        protected override void CreateChildElements()
        {
            base.CreateChildElements();
     
            StackLayoutElement stack = new StackLayoutElement();
            stack.Orientation = Orientation.Vertical;
            stack.StretchVertically = true;
            stack.StretchHorizontally = true;
     
            //first row buttons
            StackLayoutElement first = new StackLayoutElement();
            first.Orientation = Orientation.Horizontal;
            first.StretchHorizontally = true;
            first.StretchVertically = true;
     
            RadButtonElement btn1 = new RadButtonElement();
            btn1.MaxSize = new Size(20,20);
            RadButtonElement btn2 = new RadButtonElement();
            btn2.MaxSize = new Size(20,20);
            RadButtonElement btn3 = new RadButtonElement();
            btn3.MaxSize = new Size(20,20);
     
            first.Children.Add(btn1);
            first.Children.Add(btn2);
            first.Children.Add(btn3);
     
            //second row buttons
            StackLayoutElement second = new StackLayoutElement();
            second.Orientation = Orientation.Horizontal;
            second.StretchHorizontally = true;
            second.StretchVertically = true;
     
            RadButtonElement btn4 = new RadButtonElement();
            btn4.MaxSize = new Size(20,20);
            RadButtonElement btn5 = new RadButtonElement();
            btn5.MaxSize = new Size(20,20);
            RadButtonElement btn6 = new RadButtonElement();
            btn6.MaxSize = new Size(20,20);
     
            second.Children.Add(btn4);
            second.Children.Add(btn5);
            second.Children.Add(btn6);
     
            //third row buttons
            StackLayoutElement third = new StackLayoutElement();
            third.Orientation = Orientation.Horizontal;
            third.StretchHorizontally = true;
            third.StretchVertically = true;
     
            RadButtonElement btn7 = new RadButtonElement();
            btn7.MaxSize = new Size(20,20);
            RadButtonElement btn8 = new RadButtonElement();
            btn8.MaxSize = new Size(20,20);
            RadButtonElement btn9 = new RadButtonElement();
            btn9.MaxSize = new Size(20,20);
     
            third.Children.Add(btn7);
            third.Children.Add(btn8);
            third.Children.Add(btn9);
     
            stack.Children.Add(first);
            stack.Children.Add(second);
            stack.Children.Add(third);
     
            stack.Margin = new Padding(20, 0, 0, 0);
            stack.MinSize = new Size(80, 80);
            this.Children.Add(stack);
        }
    }


    I hope this information helps. Should you have further questions, I would be glad to help.

    Regards,
    Desislava
    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. UI for WinForms is Visual Studio 2017 Ready
Back to Top