RadMenuButtonItem sizing in RadDropDownButon

4 posts, 1 answers
  1. Trey
    Trey avatar
    35 posts
    Member since:
    Dec 2006

    Posted 21 Jan 2015 Link to this post

    I have a radDropDownButton that I am dynamically adding radMenuButtonItems to:

    RadMenuButtonItem bi = new RadMenuButtonItem();
    bi.Text = string.Format("Item {0}", counter);
    bi.TextAlignment = ContentAlignment.MiddleLeft;
    Font fnt = new Font("Arial Rounded MT", 18.0f);
    bi.Font = fnt;
    bi.Click += new EventHandler(radDropDownButton_Item_Click);
    bi.AutoSize = false;
    bi.Size = new Size(radDropDownButton_Caregivers.Size.Width, 50);
    radDropDownButton.Items.Add(bi);


    When I size the button item, it is sizing the space around the button item, but not the actual button item.  How can I size the button item?  See attached image (blue arrows).

    Also, how can I remove the space to the left of the button items, which is causing whitespace to the right of the button items?  See attached image (red arrows)
  2. Todor Vyagov
    Admin
    Todor Vyagov avatar
    31 posts

    Posted 22 Jan 2015 Link to this post

    Hi Trey,

    Thank you for writing.

    I edited your image and now you can see the element structure.
    You need to set the ButtonElement's property MinSize.
    RadMenuButtonItem bi = new RadMenuButtonItem();
    bi.Text = "My Item";
    bi.TextAlignment = ContentAlignment.MiddleLeft;
    Font fnt = new Font("Arial Rounded MT", 18.0f);
    bi.Font = fnt;
    bi.ButtonElement.MinSize = new Size(radDropDownButton1.Size.Width, 50);
    radDropDownButton1.Items.Add(bi);

    To remove the LeftColumnElement you can use the following code:
    RadDropDownMenuElement menuElement = this.radDropDownButton1.DropDownButtonElement.DropDownMenu.PopupElement as RadDropDownMenuElement;
    menuElement.Layout.LeftColumnMinWidth = 0;

    I hope this helps.

    Regards,
    Todor
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Trey
    Trey avatar
    35 posts
    Member since:
    Dec 2006

    Posted 22 Jan 2015 in reply to Todor Vyagov Link to this post

    Not working.

    RadMenuButtonItem ri = new RadMenuButtonItem();
    ri.Text = string.Format("Item {0}", counter); //cg.Name);
    ri.TextAlignment = ContentAlignment.MiddleLeft;
    Font fnt = new Font("Arial Rounded MT", 18.0f);
    ri.Font = fnt;
    ri.Click += new EventHandler(radDropDownButton_Item_Click);
    ri.AutoSize = true;
    ri.Size = new Size(radDropDownButton.Size.Width, 75);
    ri.MinSize = new Size(radDropDownButton.Size.Width, 75);
    radDropDownButton_Caregivers.Items.Add(ri);

    When I set AutoSize to false, it wouldn't drop down at all.
  5. Answer
    Todor Vyagov
    Admin
    Todor Vyagov avatar
    31 posts

    Posted 26 Jan 2015 Link to this post

    Hi Trey,

    Thank you for writing back.

    In order to change the RadMenuButtonItem button size you need to set its ButtonElement.MinSize property as I mentioned.
    bi.ButtonElement.MinSize = new Size(radDropDownButton1.Size.Width, 50);

    I have attached my test project. Feel free to try it and if you continue experiencing any issues get back to me with it so I can investigate the precise case. Thank you in advance.

    I am looking forward to your reply. 

    Regards,
    Todor
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top