color change

6 posts, 0 answers
  1. Abbas
    Abbas avatar
    3 posts
    Member since:
    Aug 2016

    Posted 06 Aug Link to this post

    hi

    how color change ?:

  2. Ralitsa
    Admin
    Ralitsa avatar
    176 posts

    Posted 08 Aug Link to this post

    Hello Abbas,

    Thank you for contacting Telerik support. 

    In order to change the color of the header row, you need to subscribe to the ViewCellFormatting event and apply the style you desire. Please refer to the code snippet below how to achieve it: 

    void radGridView1_ViewCellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
    {
        if (e.CellElement is Telerik.WinControls.UI.GridHeaderCellElement || e.CellElement is Telerik.WinControls.UI.GridTableHeaderCellElement)
        {
            e.CellElement.BackColor = Color.LightYellow;
            e.CellElement.NumberOfColors = 1;
            e.CellElement.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
            e.CellElement.DrawFill = true;
        }
        else
        {
            e.CellElement.ResetValue(LightVisualElement.BackColorProperty, Telerik.WinControls.ValueResetFlags.Local);
            e.CellElement.ResetValue(LightVisualElement.NumberOfColorsProperty, Telerik.WinControls.ValueResetFlags.Local);
            e.CellElement.ResetValue(LightVisualElement.GradientStyleProperty, Telerik.WinControls.ValueResetFlags.Local);
            e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, Telerik.WinControls.ValueResetFlags.Local);
        }
    }

    In order to prevent applying the formatting to other columns' cell elements, all customization should be reset for the rest of the cell elements when you use events like ViewCellFormatting and CellFormatting

    The easiest way to customize the appearance of RadScrollBar is to use our theming mechanism through the Visual Style Builder. Otherwise, you have to navigate through the Element hierarchy tree of the scroll bars in order to find the element responsible for the desired customization. Here is an example for changing the colors of the scrollbars:
    radGridView1.TableElement.VScrollBar.FillElement.BackColor = Color.LightGray;
    radGridView1.TableElement.VScrollBar.FillElement.NumberOfColors = 1;
    radGridView1.TableElement.VScrollBar.FillElement.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
     
    radGridView1.TableElement.VScrollBar.FirstButton.ButtonFill.BackColor = Color.DarkGray;
    radGridView1.TableElement.VScrollBar.FirstButton.ButtonFill.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
     
    radGridView1.TableElement.VScrollBar.SecondButton.ButtonFill.BackColor = Color.DarkGray;
    radGridView1.TableElement.VScrollBar.SecondButton.ButtonFill.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
     
    radGridView1.TableElement.VScrollBar.ThumbElement.ThumbFill.BackColor = Color.LightCyan;
    radGridView1.TableElement.VScrollBar.ThumbElement.ThumbFill.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
     
    radGridView1.TableElement.HScrollBar.FillElement.BackColor = Color.LightCoral;
    radGridView1.TableElement.HScrollBar.FillElement.NumberOfColors = 1;
    radGridView1.TableElement.HScrollBar.FillElement.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
     
    radGridView1.TableElement.HScrollBar.FirstButton.ButtonFill.BackColor = Color.LightCoral;
    radGridView1.TableElement.HScrollBar.FirstButton.ButtonFill.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
     
    radGridView1.TableElement.HScrollBar.SecondButton.ButtonFill.BackColor = Color.LightCoral;
    radGridView1.TableElement.HScrollBar.SecondButton.ButtonFill.GradientStyle = Telerik.WinControls.GradientStyles.Solid;

    I hope this helps. Let me know if you need anything else.

    Regards,
    Ralitsa
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Abbas
    Abbas avatar
    3 posts
    Member since:
    Aug 2016

    Posted 10 Aug Link to this post

    hi

    Thank

    Another question :

    how left color grid Change؟

    Please see photos

  5. Ralitsa
    Admin
    Ralitsa avatar
    176 posts

    Posted 10 Aug Link to this post

    Hi Abbas,

    Thank you for contacting us. 

    If I understand you correctly, you want to change the color behind the scrollbar thumb. In order to apply the desired color, you can use the following code: 
    Telerik.WinControls.Primitives.FillPrimitive fillBehindThumb = radGridView1.TableElement.VScrollBar.Children[1] as Telerik.WinControls.Primitives.FillPrimitive;
    fillBehindThumb.BackColor = Color.Plum;
    fillBehindThumb.NumberOfColors = 1;


    I hope this helps. Should you have further questions please do not hesitate to write back.

    Regards,
    Ralitsa
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
  6. Abbas
    Abbas avatar
    3 posts
    Member since:
    Aug 2016

    Posted 10 Aug Link to this post

    hi

    Thank  Ralitsa

    Change color and size  in pc

  7. Ralitsa
    Admin
    Ralitsa avatar
    176 posts

    Posted 12 Aug Link to this post

    Hi Abbas,

    Thank you for your reply.

    By default, the Control Default theme contains an image with three lines which is displayed in scrollbars. If you want to change the color, you need to set your image. Another option is to set the Image to null and the image won`t be visible. Please check the code snippet below: 
    ImagePrimitive imagePrimitive = radGridView1.TableElement.VScrollBar.ThumbElement.Children[2] as ImagePrimitive;
    imagePrimitive.Image = null;

    In regards to question how to change the size of scrollbars, you can use the following code:
    radGridView1.TableElement.VScrollBar.MinSize = new Size(30, 0);

    You can also change the BorderColor property of RadGridView. Here is the code snippet how to achieve it:
    radGridView1.TableElement.GridViewElement.BorderColor = Color.Aquamarine;
    radGridView1.TableElement.GridViewElement.BorderGradientStyle = Telerik.WinControls.GradientStyles.Solid;

    I have reviewed your image and one of marked borders is a cell`s border (see attached image). In order to change this border color, you need to use the ViewCellFormatting event. More information about customizing cells can be found here:  GridView >> Cells >> FormattingCells.   

    Let me know if you have any other questions.

    Regards,
    Ralitsa
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
Back to Top
UI for WinForms is Visual Studio 2017 Ready