Datagrid. Itemsource = dt. DefaultView when wpf’s DataFGrid control binds to datatable

DataGridWhen Binding datatable,

Datagrid.Itemsource=dt.DefaultView;

DataGRID will find many lines.

Solution 1 is as follows:

The operation of CanUserAddRows attribute of Datagrid is OK.

<DataGrid CanUserAddRows="False"../>

takeCanUserAddRowsAssignmentFalse,Otherwise, an extra row will be generated automatically, even thoughItemSourceBoundListAcountIt’s 0. Set to false can avoid this problem.True,Cooperate with each otherDataGridCheckBoxColumnIt’s even more strange. If the checkbox on the last line is checked, then clicking on any of the other lines will generate an extra line.

 

Solution 2 is as follows:

//Does not display the last row blank of dataGridView1.

dataGridView1.AllowUserToAddRows = false;

 

 It can be added directly to the LODE event.

 

Leave a Reply

Your email address will not be published. Required fields are marked *