且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用C#2010中的删除按钮删除***DataGridView中的选定行和整行?

更新时间:2023-12-04 11:27:10

如果您只想删除选定的行,则需要使用SelectedRows属性:

If you want to delete just the selected rows, then you need to use the SelectedRows property:
foreach (DataGridViewRow row in myDataGridView.SelectedRows)
    {
    myDataGridView.Rows.Remove(row);
    }