Monday, February 21, 2011

C# Clearing the columns in a datagridview also removes al the rows?

Does it makes sense that when columns of a datagridview are cleared, all rows are removed?

From stackoverflow
  • In a table display such a s DataGridView, if there are no columns, there cannot be any rows, and vice versa.

    Martijn : First I was somewhat surprised that all my rows were gone after clearing the columns. But when I think about it, it does makes sense :)
  • If you are removing all of the columns, then there can be no rows associated with them. You'd need at least one column in order to have rows.

  • Why don't you just toggle visibility on the column instead?

    dgv.Columns[sColumnName].Visible
    

0 comments:

Post a Comment