Controlling the background color or sizing for dead space

2 posts, 0 answers
  1. Dave
    Dave avatar
    21 posts
    Member since:
    Jan 2005

    Posted 30 Nov 2017 Link to this post

    I would like the ability to either shrink the gridview 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 contol itself and then set each row's backcolor individually perhaps to achieve this?


  2. Dimitar
    Dimitar avatar
    2951 posts

    Posted 01 Dec 2017 Link to this post

    Hi Dave,

    You need to change the BackColor of the TableElement and then of each cell:
    public RadForm1()
        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;
            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.

    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.
Back to Top