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

Raddropdownbutton

16 Answers 210 Views
Buttons, RadioButton, CheckBox, etc
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 06 Apr 2009, 05:51 PM
Im using the Raddropdownbutton and populating a list of values. When the user selects a item from the dropdown list i would like to get that item selected. How can this be done? I dont see a selecteditemindex or selectvalue anyware! The list is just a flat dropdownlist.

Please help ...and thanks in advance!

16 Answers, 1 is accepted

Sort by
0
John
Top achievements
Rank 1
answered on 06 Apr 2009, 07:59 PM
Hi Michael,
     The RadDropDownButton works a differently than a ComboBox where you select an item and the SelectionChanged event fires or you determine which index was selected.  The items for the RadDropDownButton are more like menu items where each entry will have it's own click event. 

Hope this helps,
John
0
Michael
Top achievements
Rank 1
answered on 06 Apr 2009, 08:00 PM
Can you show me an example?
0
John
Top achievements
Rank 1
answered on 06 Apr 2009, 08:08 PM

If you are adding the entry through code it would look something like this.

        private void Form1_Load(object sender, EventArgs e)  
        {  
            radDropDownButton1.Items.Clear();  
 
            //create menu item  
            var menuItem0 = new Telerik.WinControls.UI.RadMenuItem("Click me""0");  
            //add event handler  
            menuItem0.Click += new EventHandler(menuItem0_Click);  
            //add menu option to the RadDropDownButton  
            radDropDownButton1.Items.Add(menuItem0);  
        }  
 
        void menuItem0_Click(object sender, EventArgs e)  
        {  
            //perform logic for the menu item here  
            throw new NotImplementedException();  
        } 

You can of course, add these directly in the Visual Studio designer as well. 

John
0
Michael
Top achievements
Rank 1
answered on 06 Apr 2009, 08:14 PM
Ok..my menu list is dynamic it changes,so how can i find the item the user selected in the menuitem list?

Thanks again
0
John
Top achievements
Rank 1
answered on 06 Apr 2009, 08:31 PM
Well, one way is to have the RadMenuItems call the same event handler and use the Tag property to identify which item was clicked.  See the example code below. 

        private void Form1_Load(object sender, EventArgs e)  
        {  
            LoadMenuOptions(5);  
        }  
 
        private void LoadMenuOptions(int numberOfItems)  
        {  
            //remove any existing event handler references  
            foreach (Telerik.WinControls.UI.RadMenuItem entry in radDropDownButton1.Items)  
            {  
                //remove the existing event handler  
                entry.Click -= new EventHandler(menuItems_Click);  
            }  
            radDropDownButton1.Items.Clear();  
 
            for (int i = 0; i < numberOfItems; i++)  
            {  
                //create menu item  
                var currentMenuItem = new Telerik.WinControls.UI.RadMenuItem("Click me" + i.ToString(), i);  
                //add event handler  
                currentMenuItem.Click += new EventHandler(menuItems_Click);  
                //add menu option to the RadDropDownButton  
                radDropDownButton1.Items.Add(currentMenuItem);  
            }  
        }  
 
        void menuItems_Click(object sender, EventArgs e)  
        {  
            if ((int)((Telerik.WinControls.UI.RadMenuItem)sender).Tag == 0)  
            {  
                MessageBox.Show("Perform logic for option 0");  
            }  
            else if ((int)((Telerik.WinControls.UI.RadMenuItem)sender).Tag == 2)  
            {  
                MessageBox.Show("Perform logic for option 2");  
            }  
            else 
            {  
                MessageBox.Show("Perform logic for one of the other options");  
            }  
        } 

So as you can see I don't have any specific reference to a hard coded entry, the tag does not have to be an integer, I just chose that for my example. 

Hope this helps,
John
0
Michael
Top achievements
Rank 1
answered on 07 Apr 2009, 02:53 PM
Thanks John..that worked!!!
0
Ras Ran
Top achievements
Rank 2
Iron
Veteran
Iron
answered on 27 Nov 2018, 09:11 AM
how to show  Raddropdownbutton  items in mouse enter?
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 28 Nov 2018, 08:52 AM
Hello, Raneesras,  

In order to show the drop down items when the mouse is over the RadDropDownButton, you can subscribe to the 
RadDropDownButton.MouseHover event and call the ShowDropDown method:

public RadForm1()
{
    InitializeComponent();
 
    this.radDropDownButton1.MouseHover+=radDropDownButton1_MouseHover;
}
 
private void radDropDownButton1_MouseHover(object sender, EventArgs e)
{
    this.radDropDownButton1.ShowDropDown();
}

I hope this information helps. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Ras Ran
Top achievements
Rank 2
Iron
Veteran
Iron
answered on 29 Nov 2018, 06:58 AM
hello how to show  Raddropdownbutton  items on mouse enter and hide it on mouse leave ? when iam trying to hide this on  Raddropdownbutton mouse leave event i cant access Raddropdownbutton  items.. i need your help
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 29 Nov 2018, 09:20 AM
Hello, Raneesras,    

You can find below the modified code snippet how to keep the drop down opened when the mouse is over the popup:

public RadForm1()
{
    InitializeComponent();
 
    this.radDropDownButton1.MouseHover += radDropDownButton1_MouseHover;
    this.radDropDownButton1.MouseLeave += radDropDownButton1_MouseLeave;
    this.radDropDownButton1.DropDownButtonElement.DropDownMenu.MouseLeave += DropDownMenu_MouseLeave;
}
 
private void DropDownMenu_MouseLeave(object sender, EventArgs e)
{
    Point pt = this.radDropDownButton1.DropDownButtonElement.PointToControl(MousePosition);
    if (!this.radDropDownButton1.DropDownButtonElement.Bounds.Contains(pt))
    {
        this.radDropDownButton1.HideDropDown();
    }
}
 
private void radDropDownButton1_MouseLeave(object sender, EventArgs e)
{
    Point pt = this.radDropDownButton1.DropDownButtonElement.PointToControl(MousePosition);
    if (!this.radDropDownButton1.DropDownButtonElement.DropDownMenu.Bounds.Contains(pt))
    {
        this.radDropDownButton1.HideDropDown();
    }
}
 
private void radDropDownButton1_MouseHover(object sender, EventArgs e)
{
    this.radDropDownButton1.ShowDropDown();
}

I hope this information helps. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Ras Ran
Top achievements
Rank 2
Iron
Veteran
Iron
answered on 30 Nov 2018, 05:22 AM
thank you its worked
0
Ras Ran
Top achievements
Rank 2
Iron
Veteran
Iron
answered on 02 Sep 2020, 11:26 AM

hiiii....sometimes i cant access Raddropdownbutton items when mouse is leave....please look at my attached image...when i am trying to open PDC Report on the menu(attached image)...i can't access that menu items...i hope you can understand my problem

here is my code

this.radDropDownButton1.MouseHover += radDropDownButton1_MouseHover;
    this.radDropDownButton1.MouseLeave += radDropDownButton1_MouseLeave;
    this.radDropDownButton1.DropDownButtonElement.DropDownMenu.MouseLeave += DropDownMenu_MouseLeave;
 
private void DropDownMenu_MouseLeave(object sender, EventArgs e)
{
    Point pt = this.radDropDownButton1.DropDownButtonElement.PointToControl(MousePosition);
    if (!this.radDropDownButton1.DropDownButtonElement.Bounds.Contains(pt))
    {
        this.radDropDownButton1.HideDropDown();
    }
}
  
private void radDropDownButton1_MouseLeave(object sender, EventArgs e)
{
    Point pt = this.radDropDownButton1.DropDownButtonElement.PointToControl(MousePosition);
    if (!this.radDropDownButton1.DropDownButtonElement.DropDownMenu.Bounds.Contains(pt))
    {
        this.radDropDownButton1.HideDropDown();
    }
}
  
private void radDropDownButton1_MouseHover(object sender, EventArgs e)
{
    this.radDropDownButton1.ShowDropDown();
}

 

 

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 07 Sep 2020, 04:57 AM

Hello, Ras Ran,

According to the provided sample video, it seems that the drop down gets closed when the mouse leaves the item for which it is shown and the drop down itself doesn't contain focus. Please have a look at the video again and pay attention to the case when the drop down is not closed - the mouse is slightly moved from the item to the drop down. However, in the case when the drop down is not accessible, you move the mouse from the item to the space outside the item and the drop down. That is why it gets closed.

Please try to move slightly the mouse from the item directly to the drop down without hovering the space outside them. In this case, you are not expected to get the drop down closed.

I hope this information helps.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive , special prizes and more, for FREE?! Register now for DevReach 2.0(20).

0
Ras Ran
Top achievements
Rank 2
Iron
Veteran
Iron
answered on 07 Sep 2020, 11:24 AM

Thanks for the reply  Dess.....its solved anyway....i have one more doubt...how to change Raddropdownbutton RadMenuItem Back color  ?? is there any way ??

 

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 07 Sep 2020, 11:59 AM
Hello, Ras Ran,

You can change the color of a RadMenuItem by setting the RadMenuItem.FillPrimitive.BackColor property to the desired color:
            foreach (RadMenuItem item in this.radDropDownButton1.Items)
            {
                item.FillPrimitive .BackColor = Color.Yellow;
            }

I believe that you will find this information helpful for achieving your styling requirements.

Regards,
Dess | Tech Support Engineer, Sr.
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
Ras Ran
Top achievements
Rank 2
Iron
Veteran
Iron
answered on 08 Sep 2020, 09:23 AM
hii Dess........its worked perfectly....how to hide it's (RadMenuItem) border ???
Tags
Buttons, RadioButton, CheckBox, etc
Asked by
Michael
Top achievements
Rank 1
Answers by
John
Top achievements
Rank 1
Michael
Top achievements
Rank 1
Ras Ran
Top achievements
Rank 2
Iron
Veteran
Iron
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or