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

Pop-up menu with Spinner in the GridView.

8 Answers 194 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Eusebio
Top achievements
Rank 1
Veteran
Eusebio asked on 08 Jan 2021, 09:48 AM
Hello,

How can I do to put a popup menu (with right click) in the GridView ?. One of the options should be a Spinner.

Attached image.

Thank you very much.

8 Answers, 1 is accepted

Sort by
0
Nadya | Tech Support Engineer
Telerik team
answered on 08 Jan 2021, 02:59 PM

Hello, Eusebio,

According to the provided information, it seems that you would like to have a context menu in the grid with an item that shows a spinner. RadGridView provides a straightforward way to use custom context menus, instead of the default one. This context menu will appear every time the user right-clicks the RadGridView. More information is available here: https://docs.telerik.com/devtools/winforms/controls/gridview/context-menus/custom-context-menus.

I can suggest to create a custom context menu and add RadSpineEditorElement to the desired RadMenuItem. I created a sample example. Feel free to modify and extend it in a way to suits your requirements the best:

private RadContextMenu contextMenu;
public RadForm1()
{
    InitializeComponent();
    contextMenu = new RadContextMenu();
    RadMenuItem menuItem1 = new RadMenuItem();
    RadSpinEditorElement spineditor = new RadSpinEditorElement();
    menuItem1.Children.Add(spineditor);

    RadMenuItem menuItem2 = new RadMenuItem("Item 2");
    contextMenu.Items.Add(menuItem1);
    contextMenu.Items.Add(menuItem2);
   this.radGridView1.ContextMenuOpening += this.RadGridView1_ContextMenuOpening;
}

private void RadGridView1_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e)
{
    e.ContextMenu = contextMenu.DropDown;
}

I hope this information helps. If you need further assistance 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/.

0
Eusebio
Top achievements
Rank 1
Veteran
answered on 11 Jan 2021, 09:25 AM

Thanks you very much Nadya,

It's possible to put an image and label before combo?

0
Nadya | Tech Support Engineer
Telerik team
answered on 12 Jan 2021, 10:37 AM

Hi, Eusebio,

According to the provided information, I suppose that you would like to add an image and label before the RadSpineEditorElement in RadMenuItem. To do so, you can use two additional elements: for example, LightVisualElement for displaying text and ImagePrimitive for the image. You can arrange those elements in StackLayoutElement.

Below is a sample demonstration. Feel free to modify or extend it in a way to achieve the desired look. 

contextMenu = new RadContextMenu();
// first menu item
RadMenuItem menuItem1 = new RadMenuItem();
StackLayoutElement stack = new StackLayoutElement();
stack.Orientation = Orientation.Horizontal;
RadSpinEditorElement spineditor = new RadSpinEditorElement();
LightVisualElement label = new LightVisualElement();
label.Text = "Operation";

ImagePrimitive image = new ImagePrimitive();
image.Image = Resources.image;
stack.Children.Add(image);
stack.Children.Add(label);
stack.Children.Add(spineditor);
menuItem1.Children.Add(stack);

// second menu item
RadMenuItem menuItem2 = new RadMenuItem("Item 2");
contextMenu.Items.Add(menuItem1);
contextMenu.Items.Add(menuItem2);

I hope this helps. Let me know if there is anything else I can help with.

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/.

0
Eusebio
Top achievements
Rank 1
Veteran
answered on 12 Jan 2021, 11:51 AM

Thank you very much Nadya,

Currently instead of the Spinner I am using a combo.
I have tried using your code but what is not working is the combo. By clicking on the combo arrow, the list of combo items is not displayed and the menu disappears.

I attach an image.

This is mi code:

("v2": Its work)

            // Menu contextual de la grilla hoja de calculo------------------ini
            // v2: Creamos el 1er item del menu y a ese item le "insertamos" el combo.
            //rcmGrillaHC2 = new RadContextMenu();

            //// Item normal:
            //RadMenuItem menuItem1 = new RadMenuItem();

            //// Creamos el combo:
            //rmciOperarios = new RadMenuComboItem();
            //rmciOperarios.ComboBoxElement.NullText = "Selecc.operario";   // Marca de agua.
            //rmciOperarios.ComboBoxElement.SelectedIndexChanged += new Telerik.WinControls.UI.Data.PositionChangedEventHandler(rmciOperarios_SelectedIndexChanged);
            //menuItem1.Children.Add(rmciOperarios);  // Incrustamos el combo dentro de la opcion "normal" del menu.
            //rcmGrillaHC2.Items.Add(menuItem1);
            //_____________________________________________________________
            // v3: con imagen y label para el combo:
            rcmGrillaHC2 = new RadContextMenu();

            // Item normal:
            RadMenuItem menuItem1 = new RadMenuItem();

            // Creamos el combo:
            rmciOperarios = new RadMenuComboItem();
            rmciOperarios.ComboBoxElement.NullText = "Selecc.operario";   // Marca de agua.
            rmciOperarios.ComboBoxElement.SelectedIndexChanged += new Telerik.WinControls.UI.Data.PositionChangedEventHandler(rmciOperarios_SelectedIndexChanged);


            // Contenedor de controles, entre ellos el combo:
            StackLayoutElement stack = new StackLayoutElement();
            stack.Orientation = Orientation.Horizontal;

            // label:
            LightVisualElement label = new LightVisualElement();
            label.Text = "Operario:";

            // Imagen:
            ImagePrimitive image = new ImagePrimitive();
            image.Image = Resources.operario16;

            // Incrustamos en el contenedor los 3 controles:
            stack.Children.Add(image);
            stack.Children.Add(label);
            stack.Children.Add(rmciOperarios);


            //menuItem1.Children.Add(rmciOperarios);  // Incrustamos el combo dentro de la opcion "normal" del menu.
            menuItem1.Children.Add(stack);  // Incrustamos el combo(y los demas controles) dentro de la opcion "normal" del menu.

            rcmGrillaHC2.Items.Add(menuItem1);
            


            // Menu contextual de la grilla hoja de calculo------------------fin

 

 

 

0
Eusebio
Top achievements
Rank 1
Veteran
answered on 12 Jan 2021, 12:08 PM
If we remove the LightVisualElement, it works.
0
Nadya | Tech Support Engineer
Telerik team
answered on 12 Jan 2021, 01:25 PM

Hi, Eusebio,

I  assumed that you use RadSpineEditorElement since we discussed it lastly. However, the approach is similar when using RadMenuComboItem. According to your last post, it seems that you managed to solve the problems you had. I am glad that you achieved the desired context menu items. 

If you have further difficulties 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/.

0
Eusebio
Top achievements
Rank 1
Veteran
answered on 12 Jan 2021, 02:08 PM

Hi Nadya,
You don't seem to understand me. I want the label (LightVisualElement) to be included as well, but if we include it, the combo doesn't work.

Thank you very much.

0
Nadya | Tech Support Engineer
Telerik team
answered on 13 Jan 2021, 02:26 PM

Hello, Eusebio,

Please excuse me that I did not understand you correctly. It seems that you want to have the ImagePrimitive, LighVisualElement, and RadMenuComboItem in the menu item. I used the provided code snippet in my project and was able to observe the same behavior as you described. 

After investigating the case further it seems that the StackLayoutPanelElement is not hit tested correctly in this scenario. This is why I can suggest replacing the StackLayoutPanelElement with StackLayoutPanel. Once, I used the StackLayoutPanel the problem with closing the menu disappears and is working correctly now. Can you give this solution a try and let me know how it works for you.

public RadForm1()
{
    InitializeComponent();

    contextMenu = new RadContextMenu();

    RadMenuItem menuItem1 = new RadMenuItem();
    RadMenuItem menuItem2 = new RadMenuItem("Item 2");

    StackLayoutPanel stack = new StackLayoutPanel();
    stack.Orientation = Orientation.Horizontal;

    RadMenuComboItem comboItem = new RadMenuComboItem();
    comboItem.ComboBoxElement.NullText = "Selecc.operario";

    LightVisualElement label = new LightVisualElement();
    label.Text = "Operation";

    ImagePrimitive image = new ImagePrimitive();
    image.Image = Resources.image;

    stack.Children.Add(image);
    stack.Children.Add(label);
    stack.Children.Add(comboItem);

    menuItem1.Children.Add(stack);
    
    contextMenu.Items.Add(menuItem1);
    contextMenu.Items.Add(menuItem2);
}

I hope this helps. If you need further assistance 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
Eusebio
Top achievements
Rank 1
Veteran
Answers by
Nadya | Tech Support Engineer
Telerik team
Eusebio
Top achievements
Rank 1
Veteran
Share this question
or