How to hide column of DataGridView when using custom DataSource?

前端 未结 7 1656
时光取名叫无心
时光取名叫无心 2020-12-08 20:07

I have a small app in c#, it has a DataGridView that gets filled using:

grid.DataSource = MyDatasource array;

MyClass hold the structure for the

相关标签:
7条回答
  • 2020-12-08 20:35

    I have noticed that if utilised progrmmatically it renders incomplete (entire form simply doesn't "paint" anything) if used before panel1.Controls.Add(dataGridView); then dataGridView.Columns["ID"].Visible = false; will break the entire form and make it blank, so to get round that set this AFTER EG:

     panel1.Controls.Add(dataGridView);
     dataGridView.Columns["ID"].Visible = false; 
     //works
    
     dataGridView.Columns["ID"].Visible = false; 
     panel1.Controls.Add(dataGridView);
     //fails miserably
    
    0 讨论(0)
提交回复
热议问题