How to change RadForm background gradient at runtime?

2 posts, 0 answers
  1. Mark
    Mark avatar
    8 posts
    Member since:
    Jun 2011

    Posted 04 May 2012 Link to this post


    Is there anyway i can change the background gradient of a RadForm at runtime? If so, how can i do it?

    I have multiple forms, and some of them will have different gradients, so i would to be able to change the gradients at runtime so i don't have to create a ton of different theme files for each form.

    Please let me know if this is possible.
  2. Stefan
    Stefan avatar
    2906 posts

    Posted 09 May 2012 Link to this post

    Hi Mark,

    Thank you for writing.

    The form itself cannot have gradients. It can only have its BackColor set. However, you can easily achieve gradients as form's back color, by docking a panel in the form (which support gradients) and use it as controls container. Here is a sample:
    RadPanel panel = new RadPanel();
    panel.Dock = DockStyle.Fill;
    panel.PanelElement.PanelFill.BackColor = Color.Red;
    panel.PanelElement.PanelFill.BackColor2 = Color.Blue;
    panel.PanelElement.PanelFill.BackColor3 = Color.Yellow;
    panel.PanelElement.PanelFill.BackColor4 = Color.Green;
    panel.PanelElement.PanelFill.NumberOfColors = 4;
    panel.PanelElement.PanelFill.GradientStyle = Telerik.WinControls.GradientStyles.Linear;

    I hope that the provided information addresses your question. Should you have any other questions, do not hesitate to contact us.
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Back to Top