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

Controlling the background color or sizing for dead space

1 Answer 51 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Dave
Top achievements
Rank 1
Dave asked on 30 Nov 2017, 06:45 PM

I would like the ability to either shrink the to fit the number of rows it has (thereby showing the background color below it) or to control the color of the dead space separately from the background color or alternating row color.

Could I change the background color of the  itself and then set each row's  individually perhaps to achieve this?

 

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 01 Dec 2017, 10:59 AM
Hi Dave,

You need to change the BackColor of the TableElement and then of each cell:
public RadForm1()
{
    InitializeComponent();
 
    radGridView1.TableElement.BackColor = Color.Red;
    radGridView1.ViewCellFormatting += RadGridView1_ViewCellFormatting1;
}
 
private void RadGridView1_ViewCellFormatting1(object sender, CellFormattingEventArgs e)
{
    if (!e.Row.IsCurrent && e.CellElement.GetType() != typeof(GridHeaderCellElement) && e.CellElement.GetType() != typeof(GridTableHeaderCellElement))
    {
        e.CellElement.DrawFill = true;
        e.CellElement.BackColor = Color.White;
        e.CellElement.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
 
    }
    else
    {
        e.CellElement.ResetValue(LightVisualElement.BackColorProperty, Telerik.WinControls.ValueResetFlags.Local);
        e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, Telerik.WinControls.ValueResetFlags.Local);
        e.CellElement.ResetValue(LightVisualElement.GradientStyleProperty, Telerik.WinControls.ValueResetFlags.Local);
    }
}
 
I hope this will be useful. Let me know if you have additional questions.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
GridView
Asked by
Dave
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or