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

RadbuttonElement inside a RadMenuItem

2 Answers 99 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Leandro
Top achievements
Rank 1
Leandro asked on 12 Oct 2020, 03:31 PM

     Hey, I have a RadMenu, and what I'm trying to do is to put a RadButtonElement inside a RadMenuItem, but I can't find where and how to do it right, since it aways go to wrong position. This was my last try:

var item = new RadButtonElement
            {
                Text = "?",
                CaptureOnMouseDown = true,
                ShouldHandleMouseInput = true,
                StretchHorizontally = false,
                StretchVertically = true,
                NotifyParentOnMouseInput = false,
                Margin = new Padding(5),
                Alignment  = ContentAlignment.MiddleRight,
            };
            item.Font = new Font(item.Font, FontStyle.Bold);
            item.Click += Item_Click;
            btnCotacao.Layout.Children.Add(item);

2 Answers, 1 is accepted

Sort by
0
Leandro
Top achievements
Rank 1
answered on 12 Oct 2020, 03:37 PM
forget it, I've just found the solution on the next post: https://www.telerik.com/forums/close-items-directly-from-a-mdilist
0
Accepted
Nadya | Tech Support Engineer
Telerik team
answered on 12 Oct 2020, 03:46 PM

Hello, Leandro,

Thank you for the provided code snippet.

Following the provided description it seems that you want to add the RadButtonElement after the text and align it to the right of the menu item. To achieve this you should add the RadButtonElement directly to the Children collection of the RadMenuItem, not to the Layout collection. Please refer to your code snippet updated:

public RadForm1()
{
    InitializeComponent();

    var item = new RadButtonElement
    {
        Text = "?",
        CaptureOnMouseDown = true,
        ShouldHandleMouseInput = true,
        StretchHorizontally = false,
        StretchVertically = true,
        NotifyParentOnMouseInput = false,
        Margin = new Padding(5),
        Alignment = ContentAlignment.MiddleRight,
    };
    item.Font = new Font(item.Font, FontStyle.Bold);
    item.Click += Item_Click;
   radMenuItem5.Children.Add(item);
}

I hope this helps. Should you have any other questions do not hesitate to contact me.

Regards,
Nadya
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Menu
Asked by
Leandro
Top achievements
Rank 1
Answers by
Leandro
Top achievements
Rank 1
Nadya | Tech Support Engineer
Telerik team
Share this question
or