Datagridview column remove doesn't work

0
0

After binding a DataView to a DataGridView I tried to remove a Column with :

DataGridView1.Columns.Remove(“FieldToBeRemoved”)

Unfortunately this does not work, the field is still visible in the DataGridView..

Is this behaviour intended? And if so, is it possible to set the Columns in the ShowColumnVisibilityMenu programatically?

This would solve the problem.

 

Regards, Wim

 

 

 

  • You must to post comments
0
0

Hi Frank,

 

Turn of AutoGenerateColumns does the trick 🙂 !

Thanks,

Regards,

Wim

  • You must to post comments
0
0

Hi Wim,

I have tried this in a small sample but could not reproduce.

You can try

  • To Turn off AutoGenerateColumns of the DataGridView right before removing the Column
  • To hide the Column instead of removing it (set visible = false).

If both approaches won´t work for you please send us a small test case and we´ll check on our end.

Best regards
Frank

  • Laurent
    This is quite old, but I also had weird problems with dynamic column removal. Just FYI, doing a .Dispose() of a column just after having removed it solved my issues;
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.