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

color change

5 Answers 521 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Abbas
Top achievements
Rank 1
Abbas asked on 06 Aug 2016, 08:47 AM

hi

how color change ?:

5 Answers, 1 is accepted

Sort by
0
Ralitsa
Telerik team
answered on 08 Aug 2016, 08:30 AM
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.
0
Abbas
Top achievements
Rank 1
answered on 10 Aug 2016, 05:21 AM

hi

Thank

Another question :

how left color grid ChangeØŸ

Please see photos

0
Ralitsa
Telerik team
answered on 10 Aug 2016, 06:47 AM
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.
0
Abbas
Top achievements
Rank 1
answered on 11 Aug 2016, 04:44 AM

hi

Thank  Ralitsa

Change color and size  in pc

0
Ralitsa
Telerik team
answered on 12 Aug 2016, 04:09 PM
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 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.
Tags
GridView
Asked by
Abbas
Top achievements
Rank 1
Answers by
Ralitsa
Telerik team
Abbas
Top achievements
Rank 1
Share this question
or