Start Icon menu items and subitems width problem

4 posts, 0 answers
  1. hema
    hema avatar
    16 posts
    Member since:
    Mar 2011

    Posted 14 Jul 2011 Link to this post

    Hi,

               I have added menu items and submenu items to the start icon in the radribbion bar .But  the width and hegiht is not proper for submenuitems.

    Please refer the screenshots

    I  am getting as in screen (submenuheight) but i want it as shown in screen(sample).

    How can i do it any propery .


    Thanks
    Hema
  2. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 19 Jul 2011 Link to this post

    Hello Hema,

    Thank you for writing.

    The observed behavior is caused, because all RadMenuItems are sizing themselves according to their content. In your case you have added images to some of the items and they sized themselves according to the image size. However, if you want to have all items with size equal to the biggest item size, please consider the following snippet:
    public Form1()
          {
              InitializeComponent();
     
              radRibbonBar1.RibbonBarElement.ApplicationButtonElement.DropDownOpening += new CancelEventHandler(ApplicationButtonElement_DropDownOpening);
          }
     
          void ApplicationButtonElement_DropDownOpening(object sender, CancelEventArgs e)
          {
              int maxHeight = 0;
              foreach (RadMenuItem item in radRibbonBar1.StartMenuItems)
              {
                  if (item.Size.Height > maxHeight)
                  {
                      maxHeight = item.Size.Height;
                  }
              }
              foreach (RadMenuItem item in radRibbonBar1.StartMenuItems)
              {
                  item.MinSize = new Size(item.Size.Width, maxHeight);
              }
          }

    I hope that you find this information helpful. Should you have any other questions, do not hesitate to contact us.
     
    Kind regards,
    Stefan
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. UI for WinForms is Visual Studio 2017 Ready
  4. hema
    hema avatar
    16 posts
    Member since:
    Mar 2011

    Posted 19 Jul 2011 Link to this post

    Hi,

           Thanks the height for the main menus is set.

    But now my issue is the submenuitems should  be displayes exactly beside the main menu item as in screen(sample.jpg).But the submenu items are displaying from the top as in (screebshot2.jpg).

    So how can i get it ....


    Thanks in Adavance
    Hema
  5. Jack
    Admin
    Jack avatar
    2335 posts

    Posted 22 Jul 2011 Link to this post

    Hi Hema,

    This is the default application menu behavior as specified by MS RibbonBar specification. You can customize it by handling the DropDownOpening event. Here is a sample:
    RadMenuItem item = (RadMenuItem)menu.Items[2];
    item.DropDownOpening += new CancelEventHandler(item_DropDownOpening);
     
    void item_DropDownOpening(object sender, CancelEventArgs e)
    {
        RadMenuItem item = (RadMenuItem)sender;
        RadPopupOpeningEventArgs args = (RadPopupOpeningEventArgs)e;
        Point pt = item.ElementTree.Control.PointToScreen(new Point(0, item.ControlBoundingRectangle.Y));
        args.CustomLocation = new Point(args.CustomLocation.X, pt.Y);
        item.DropDown.MinimumSize = Size.Empty;
    }

    Please note that the first level menu width is controlled by the RightColumnWidth property:
    menu.ShowTwoColumnDropDownMenu = false;
    menu.RightColumnWidth = 100;

    If you have further questions, I will be glad to assist you.
     
    Greetings,
    Jack
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Back to Top