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

ComboBox in a ContextMenu

2 Answers 357 Views
ContextMenu
This is a migrated thread and some comments may be shown as answers.
Adi
Top achievements
Rank 1
Adi asked on 02 Aug 2013, 04:06 AM
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 Answers, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 06 Aug 2013, 02:34 PM
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 >>
0
Adi
Top achievements
Rank 1
answered on 07 Aug 2013, 06:22 AM
Hi Desislava,

Your solution works great !!
Thanks a lot.

Regards,

ADi Kurniawan
Tags
ContextMenu
Asked by
Adi
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Adi
Top achievements
Rank 1
Share this question
or