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

How to set background Color in a DropDownButton

8 Answers 874 Views
Buttons, RadioButton, CheckBox, etc
This is a migrated thread and some comments may be shown as answers.
Shaun
Top achievements
Rank 1
Shaun asked on 08 Oct 2013, 02:58 AM
Hi,

How can I set the dropdownbutton background color to transparent?
I can get the main part of the button to be transparent, but when I hit the dropdown the backgound color is not changing.

I have tried to edit the fill primitive via the Edit IU elements but with no luck.

Cheers

Shaun


8 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 10 Oct 2013, 03:32 PM
Hello Shaun,

Thank you for contacting Telerik Support.

In order to make RadDropDownButton transparent, please have a look at the following code snippet:
//action button
radDropDownButton1.DropDownButtonElement.ActionButton.ButtonFillElement.BackColor =
    Color.Transparent;
radDropDownButton1.DropDownButtonElement.ActionButton.ButtonFillElement.GradientStyle =
    Telerik.WinControls.GradientStyles.Solid;
 
//arrow button
radDropDownButton1.DropDownButtonElement.ArrowButton.Fill.BackColor =
    Color.Transparent;
radDropDownButton1.DropDownButtonElement.ArrowButton.Fill.GradientStyle =
    Telerik.WinControls.GradientStyles.Solid;

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
Shaun
Top achievements
Rank 1
answered on 11 Oct 2013, 01:48 AM
Hi,

Thanks for that but can I make the background of the dropdown menu items transparent too.
So in other works when you hit the dropdown button a menu list appears, its this area I want to make transparent, the area that only appear when the button is clicked.

Cheers

Shaun.
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 15 Oct 2013, 12:54 PM
Hello Shaun,

Thank you for writing back.

In order to obtain transparent drop down menu, please have a look at the following code snippet:
//drop down menu
radDropDownButton1.DropDownButtonElement.DropDownMenu.BackColor = Color.Transparent;
RadDropDownMenuElement ddme = (RadDropDownMenuElement)radDropDownButton1.DropDownButtonElement.DropDownMenu.PopupElement;
ddme.Fill.BackColor = Color.Transparent;
ddme.LeftColumnFill.BackColor = Color.Transparent;

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
Oliver
Top achievements
Rank 1
answered on 19 Nov 2015, 12:38 PM

Hello all,

Shaun`s statement helped me to make the background of the Item-menu white:

RadDropDownMenuElement ddmeD3E = (RadDropDownMenuElement)btn_main_Strukturauswahl_Speichern.DropDownButtonElement.DropDownMenu.PopupElement;
            ddmeD3E.Fill.BackColor = Color.White;
            ddmeD3E.Fill.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
            ddmeD3E.LeftColumnFill.BackColor = Color.White;
            ddmeD3E.LeftColumnFill.GradientStyle = Telerik.WinControls.GradientStyles.Solid;

Only a few detail is missing to made my solution perfekt.

Our Customer wants  to habe a black background with white text,  when he hover over an Item of the DropDownButton.
Else he wants a white background with black test.

Can you, or anyone else, help me at this task?

I can`t find a method like "Item-Mouse-Hover".

Thank`s a lot.

Kind regards
Oliver

 

0
Oliver
Top achievements
Rank 1
answered on 19 Nov 2015, 01:40 PM

Hello,

 i`m closer.

I added the Item-MouseHover and Item-MouseLeave Events in the form-designer.

Now, i can react to the Hover:

    private void radMenuItem9_MouseHover(object sender, EventArgs e)

        {
            radMenuItem9.BackColor = Color.Black;
            radMenuItem9.ForeColor = Color.White;
        }
        private void radMenuItem9_MouseLeave(object sender, EventArgs e)
        {
            radMenuItem9.BackColor = Color.White;
            radMenuItem9.ForeColor = Color.Black;
        }

But the backcolor didn`t change.

I only see white text over white background.

Maybe the Hovercolor overlays the backcolor.

Die Fillcolor for the whole Itemlist is definded as white, too,

Can anyone help.

Thanks.

0
Oliver
Top achievements
Rank 1
answered on 19 Nov 2015, 02:09 PM

Hi,

it`s me again.

My solution is:

Add the Mousemove and MouseLeave events manually to the form designer.

Then use:

 private void  btn_Dokument_Speichern_MouseHover(object sender, EventArgs e)
        {
            btn_Dokument_Speichern.FillPrimitive.BackColor = Color.Black;
            btn_Dokument_Speichern.ForeColor = Color.White;
        }
    
        private void btn_Dokument_Speichern_MouseLeave(object sender, EventArgs e)
        {
            btn_Dokument_Speichern.FillPrimitive.BackColor = Color.White;
            btn_Dokument_Speichern.ForeColor = Color.Black;
        }

Though the color changes lethargic.

It need a second to change the color.

If someone had a better solution don`t hesitate to post your way.

Thanks.
Oliver

 

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 20 Nov 2015, 01:33 PM
Hello Oliver,

Thank you for writing.

It is suitable to use the MouseEnter and MouseLeave events in order to achieve the desired style. Here is a sample code snippet which result is illustrated on the attached gif file:
public Form1()
{
    InitializeComponent();
 
    foreach (RadMenuItem item in this.radMenuItem1.Items)
    {
        item.MouseEnter+=item_MouseEnter;
        item.MouseLeave+=item_MouseLeave;
    }
}
 
private void item_MouseLeave(object sender, EventArgs e)
{
    RadMenuItem item = sender as RadMenuItem;
    item.FillPrimitive.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
    item.ResetValue(LightVisualElement.ForeColorProperty, ValueResetFlags.Local);
}
 
private void item_MouseEnter(object sender, EventArgs e)
{
    RadMenuItem item = sender as RadMenuItem;
    item.FillPrimitive.BackColor = Color.Black;
    item.ForeColor = Color.White;
}

Note that this thread is related to RadDropDownButton. However, it seems that your question is regarding RadMenu. I would kindly ask you to open a separate thread with the appropriate Product (RadMenu for WinForms) and to avoid mixing different subjects in the same thread in future. This will also give you the opportunity to track the different cases easily. Thank you for your understanding.
 
Regards,
Dess
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Oliver
Top achievements
Rank 1
answered on 20 Nov 2015, 01:59 PM

Thank you Dess for the nice sample.

I`ll pimp up my sources.

Thanks a lot.

Olli 

 

Tags
Buttons, RadioButton, CheckBox, etc
Asked by
Shaun
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Shaun
Top achievements
Rank 1
Oliver
Top achievements
Rank 1
Share this question
or