25

I have binded a datagridview to a datatable. But the gridview displays an extra empty row at the bottom ? How should I hide it ? Thanks in Advance

Ananth
  • 10,330
  • 24
  • 82
  • 109

2 Answers2

51

The extra row is to manually add a line to your datagridview. If you don't need it you can disable it by disallowing the user to add rows:

this.dataGridView.AllowUserToAddRows = false;
Jla
  • 11,304
  • 14
  • 61
  • 84
  • I spent an hour hunting through XML-parsing code, thinking something was being imported incorrectly...thanks! :) – Alex Sep 03 '13 at 16:38
  • 1
    I found this looking for an answer to just a DataGrid. It's property equivalent is `CanUserAddRows`. – ian.aldrighetti Apr 29 '15 at 18:21
1

You can try this:

CurrencyManager cm = myGrid.BindingContext[myGrid.DataSource, myGrid.DataMember] 
                     as CurrencyManager;
DataView dv = cm.List as DataView;
dv.AllowNew = false;
Edwin de Koning
  • 14,209
  • 7
  • 56
  • 74