How do I remove the empty row from the bottom of a DataGridView control?

后端 未结 2 1324
野的像风
野的像风 2020-12-15 02:31

When I fill a DataGridView with data, there is always an empty row at the bottom. How do I disable this?

相关标签:
2条回答
  • 2020-12-15 02:59

    If you are having trouble with this in WPF add:

    CanUserAddRows="False"
    

    To the properties of the desired datagrid in XAML.

    0 讨论(0)
  • 2020-12-15 03:14

    Yes, there will always be an empty row at the bottom of a DataGridView. It allows the user to add new data at run-time; all they have to do is start typing in the new row.

    To disable it, you will also need to prevent the user from adding new rows. Do this by setting the AllowUserToAddRows property of your DataGridView control to False:

    myDataGridView.AllowUserToAddRows = false;
    
    0 讨论(0)
提交回复
热议问题