How to hide Column In Telerik RadGrid which all cells are null

2 posts, 0 answers
  1. Sanjeewa
    Sanjeewa avatar
    1 posts
    Member since:
    Jul 2015

    Posted 01 Dec 2016 Link to this post

    I was new to telerik.
    I want to hide columns in radgridview which column all cells are null values by programmatically.


  2. Dimitar
    Dimitar avatar
    2949 posts

    Posted 02 Dec 2016 Link to this post

    Hello Sanjeewa,

    Thank you for writing.

    To achieve this you need to iterate all rows and columns see if all values are null:
    private void RadButton1_Click(object sender, EventArgs e)
        foreach (var col in radGridView1.Columns)
            bool valueFound = false;
            foreach (var row in radGridView1.Rows)
                if (row.Cells[col.Name].Value != null && row.Cells[col.Name].Value != DBNull.Value)
                    valueFound = true;
            col.IsVisible = valueFound;

    I have noticed that this question is posted twice and I have deleted the other post. 

    I hope this will be useful. Let me know if you have additional questions.

    Telerik by Progress
    Telerik UI for WinForms is ready for Visual Studio 2017 RC! Learn more.
Back to Top