Managing Styles through code

6 posts, 1 answers
  1. Jean-Marc Windholz
    Jean-Marc Windholz avatar
    42 posts
    Member since:
    Sep 2009

    Posted 03 Dec 2010 Link to this post

    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,

  2. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 05 Dec 2010 Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Jack
    Admin
    Jack avatar
    2335 posts

    Posted 09 Dec 2010 Link to this post

    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.
  5. Jean-Marc Windholz
    Jean-Marc Windholz avatar
    42 posts
    Member since:
    Sep 2009

    Posted 09 Dec 2010 Link to this post

    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.

  6. Answer
    Dobry Zranchev
    Admin
    Dobry Zranchev avatar
    348 posts

    Posted 15 Dec 2010 Link to this post

    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.
  7. Jean-Marc Windholz
    Jean-Marc Windholz avatar
    42 posts
    Member since:
    Sep 2009

    Posted 15 Dec 2010 Link to this post

    Thank you for your answer ! Now it seems to work ..... finally!
Back to Top
UI for WinForms is Visual Studio 2017 Ready