ComboBox in a ContextMenu

3 posts, 1 answers
  1. Adi
    Adi avatar
    2 posts
    Member since:
    Aug 2013

    Posted 01 Aug 2013 Link to this post

    Hi Telerik Team,

    I'm trying to put a ComboBox inside a ContextMenu. Would you be able to advise us on how to fix this issue ?
    My code is working but there seems to be a visual issue where the tip of the combobox is cut as seen in the picture attached.
    Here is my code (some of it is hardcoded and taken directly from the demo)
    RadContextMenu contextMenu = new RadContextMenu();
    RadMenuItem menuItem = new RadMenuItem("Add Item");
    RadDropDownList fontDropDownList = new RadDropDownList();
    //fontDropDownList.Margin = new Padding(25, 5, 5, 5);
    fontDropDownList.Text = "Select Font";
    fontDropDownList.Items.Add(new RadListDataItem("Arial"));
    fontDropDownList.Items.Add(new RadListDataItem("Tahoma"));
    fontDropDownList.Items.Add(new RadListDataItem("Times New Roman"));
    fontDropDownList.Items.Add(new RadListDataItem("Verdana"));
                 
    RadMenuContentItem contentItem = new RadMenuContentItem();
    contentItem.ContentElement = new RadHostItem(fontDropDownList);
    contentItem.MinSize = new System.Drawing.Size(150, 100);
    menuItem.Items.Add(contentItem);
    contextMenu.Items.Add(menuItem);

    Would you be able to advise us on how to fix this issue ? Thanks in advance. Regards, Adi Kurniawan

  2. Answer
    Dess
    Admin
    Dess avatar
    1609 posts

    Posted 06 Aug 2013 Link to this post

    Hello Adi,

    Thank you for contacting Telerik Support.

    I have modified a little bit your code to obtain the results from the attached picture:
    private void Form1_Load(object sender, EventArgs e)
            {
                // TODO: This line of code loads data into the 'nwindDataSet.Customers' table. You can move, or remove it, as needed.
                this.customersTableAdapter.Fill(this.nwindDataSet.Customers);
     
                contextMenu = new RadContextMenu();
                RadMenuItem menuItem = new RadMenuItem("Add Item");
                RadDropDownList fontDropDownList = new RadDropDownList();
                fontDropDownList.Text = "Select Font";
                fontDropDownList.Items.Add(new RadListDataItem("Arial"));
                fontDropDownList.Items.Add(new RadListDataItem("Tahoma"));
                fontDropDownList.Items.Add(new RadListDataItem("Times New Roman"));
                fontDropDownList.Items.Add(new RadListDataItem("Verdana"));
     
                RadMenuContentItem contentItem = new RadMenuContentItem();
                RadHostItem host = new RadHostItem(fontDropDownList);
                contentItem.ContentElement = host;
     
                contentItem.AutoSize = false;
                contentItem.Size = new System.Drawing.Size(150, 100);
                menuItem.Items.Add(contentItem);
                contextMenu.Items.Add(menuItem);
            }
     
            private void radGridView1_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e)
            {
                e.ContextMenu = contextMenu.DropDown;
            }

    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
  4. Adi
    Adi avatar
    2 posts
    Member since:
    Aug 2013

    Posted 07 Aug 2013 Link to this post

    Hi Desislava,

    Your solution works great !!
    Thanks a lot.

    Regards,

    ADi Kurniawan
Back to Top