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

Change backgroud of button and when mouse over

1 Answer 1351 Views
Buttons, RadioButton, CheckBox, etc
This is a migrated thread and some comments may be shown as answers.
Doraemon
Top achievements
Rank 1
Doraemon asked on 16 Apr 2014, 04:42 AM
Hi,

I want to change background of button. I set FillPrimitive/ BackColor 1- 4 to Blue and background of the button is changed to Blue. But when I move my mouse over the button, background of the button isn't changed to other color.

1. I want my button background is blue, when I move my mouse over it, the background is changed to yellow or other color. How can I do this ?
2. I have a lot of buttons in my application so I want apply above style to all my button, How can I do this ?

Thanks.

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 16 Apr 2014, 08:18 AM
Hello James,

Thank you for writing.

This is expected because setting the color in code overrides the theme (as it has higher priority) and the color for the mouse over state is not changed. More information about how our theming functionality works can be found in the following articles: 
This can be very easily overridden by using Visual Style Builder to change the color for the appropriate state. The attached image illustrates how you can change the button color. Also you may find the following articles very useful when you need to use Visual Style Builder: 
Also you can handle this case in code. To do that you should subscribe to the MouseLeave and MouseEnter events (same handlers can be used for all your buttons):
void radButton1_MouseLeave(object sender, EventArgs e)
{
    radButton1.ButtonElement.ButtonFillElement.BackColor = Color.FromArgb(153, 204, 55);
}
  
void radButton1_MouseEnter(object sender, EventArgs e)
{
    radButton1.ButtonElement.ButtonFillElement.BackColor = Color.FromArgb(153, 204, 255);
}

I hope this helps. Should you have any other questions do not hesitate to ask.
 
Regards,
Dimitar
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Buttons, RadioButton, CheckBox, etc
Asked by
Doraemon
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or