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

Managing Styles through code

5 Answers 116 Views
Buttons, RadioButton, CheckBox, etc
This is a migrated thread and some comments may be shown as answers.
Jean-Marc Windholz
Top achievements
Rank 1
Jean-Marc Windholz asked on 03 Dec 2010, 03:56 PM
Hi,

I need to make the selection of the RadSplitButton when RadDropDownButtonElement is selected. For make this, I'm changing Style Parameter of the different buttons and when another button is Selected I have to restore Original Values.

For make this, I've made one event:

public void SelectedChanged(object sender,EventArgs e){


            RadSplitButtonElement SendingSplitButton = sender as RadSplitButtonElement;
            RadSplitButtonElement[] ButtonArray = { orbit, rotate, horizontalMove, verticalMove, zoom };

 for (int i = 0; i < 5; i++)
            {
                ButtonArray[i].ActionButton.ButtonFillElement.BackColor = System.Drawing.Color.transparent;  <- Setting the original Values
                ButtonArray[i].ActionButton.ButtonFillElement.BackColor2 = System.Drawing.Color.transparent;
                ButtonArray[i].ActionButton.ButtonFillElement.BackColor3 = System.Drawing.Color.transparent;
                ButtonArray[i].ActionButton.ButtonFillElement.BackColor4 = System.Drawing.Color.transparent;              

            }
           /*Setting Selected Values...*/
            SendingSplitButton.ActionButton.ButtonFillElement.BackColor = System.Drawing.Color.FromArgb(255,255,115,0);
            SendingSplitButton.ActionButton.ButtonFillElement.BackColor2 = System.Drawing.Color.FromArgb(255,255, 115, 0);
            SendingSplitButton.ActionButton.ButtonFillElement.BackColor3 = System.Drawing.Color.FromArgb(255,255, 115, 0);
            SendingSplitButton.ActionButton.ButtonFillElement.BackColor4 = System.Drawing.Color.FromArgb(255,255, 115, 0);
            SendingSplitButton.ActionButton.ButtonFillElement.GradientPercentage = 0.62f;
            SendingSplitButton.ActionButton.ButtonFillElement.GradientPercentage = 0.71f;
}

I have already tried changing the State of the Objects in this mode:

SendingSplitButton.OnMouseOver = true or with SendingSplitButton.OnMouseDown= true but it doesn't work. I don't understand very well if it is possible or not managing only a single state of the object through the code and how the Style Managing - by code - and Xml is merged.

Thank you very Much,

5 Answers, 1 is accepted

Sort by
0
Richard Slade
Top achievements
Rank 2
answered on 05 Dec 2010, 11:23 PM
Hello Jean-Marc,

I'd like to get a clearer understanding of what you are trying to do. Please could you explain in more detail. It sounds as if you are trying to change colours of the RadSplitButton depending on which item in the split button is selected. Is that correct?

Let me know and I'll do my best to help
Richard
0
Jack
Telerik team
answered on 09 Dec 2010, 02:34 PM
Hello Jean-Marc Windholz, please find the answer to your question in this forum thread. Please avoid posting one and the same question in different threads, because this may slow down our response.

If you have any other questions, I will be glad to help.
 
Regards,
Jack
the Telerik team
Get started with RadControls for WinForms with numerous videos and detailed documentation.
0
Jean-Marc Windholz
Top achievements
Rank 1
answered on 09 Dec 2010, 03:41 PM
I try to explain better.
What I want to do: I want to highlight the selected button keeping the normal mouseon graphics effect for the other buttons of the container.
You can se in NormalMouseON.png the first button selected and the normal graphics effect of the mouseon on the third button.

When I selected a button, I have to loop in the container to set the base graphics parameters to the buttons, and then set the "highlight" parameters
for the selected button, this to change the aspect to the previous selected button.
In I do this operation, I loose the normal mouseon effect and this becomes like in AbnormalMouseon.png for the second button, without the yellow filling of the button, but highlighting only the borders and the arrow.

0
Accepted
Dobry Zranchev
Telerik team
answered on 15 Dec 2010, 11:55 AM
Hello Jean-Marc Windholz,

Thank you for writing back.

RadSplitButton is a composite button which contains two main elements (ArrowButton, ActionButton). After looking at code snippet I noticed that you modify the ActionButton part. You do not get the mouse hover fill because of the properties that you have set to the fill of the ActionButton part. The priority of the locally set values is higher than the priority of the values set by the theme. So, you should reset all properties that are set locally in order to see the style coming from the theme:
this.radSplitButton1.DropDownButtonElement.ActionButton.ButtonFillElement.ResetValue(RadItem.BackColorProperty, ValueResetFlags.Local);
this
.radSplitButton1.DropDownButtonElement.ActionButton.ButtonFillElement.ResetValue(FillPrimitive.BackColor2Property, ValueResetFlags.Local);
this.radSplitButton1.DropDownButtonElement.ActionButton.ButtonFillElement.ResetValue(FillPrimitive.BackColor3Property, ValueResetFlags.Local);
this.radSplitButton1.DropDownButtonElement.ActionButton.ButtonFillElement.ResetValue(FillPrimitive.BackColor4Property, ValueResetFlags.Local);
this
.radSplitButton1.DropDownButtonElement.ActionButton.ButtonFillElement.ResetValue(FillPrimitive.GradientPercentageProperty, ValueResetFlags.Local);
this.radSplitButton1.DropDownButtonElement.ActionButton.ButtonFillElement.ResetValue(FillPrimitive.GradientPercentage2Property, ValueResetFlags.Local);

In case you have further questions, feel free to write back.

Regards,
Dobry Zranchev
the Telerik team
Check out the Q1 2011 Roadmap for Telerik Controls for Windows Forms.
0
Jean-Marc Windholz
Top achievements
Rank 1
answered on 15 Dec 2010, 02:23 PM
Thank you for your answer ! Now it seems to work ..... finally!
Tags
Buttons, RadioButton, CheckBox, etc
Asked by
Jean-Marc Windholz
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
Jack
Telerik team
Jean-Marc Windholz
Top achievements
Rank 1
Dobry Zranchev
Telerik team
Share this question
or