DevExpress实现GridControl删除所有行的方法

时间:2024-04-10 18:05:22
/// <summary>
/// 删除全部行
/// </summary>
/// <param name="gridView">GridView</param>
public static void ClearRows(this GridView gridView)
{
bool _mutilSelected = gridView.OptionsSelection.MultiSelect;//获取当前是否可以多选
if (!_mutilSelected)
gridView.OptionsSelection.MultiSelect = true;
gridView.SelectAll();
gridView.DeleteSelectedRows();
gridView.OptionsSelection.MultiSelect = _mutilSelected;//还原之前是否可以多选状态
}

代码使用方法如下:

gcLampConfig.UIThread<GridControl>(gc => gvLampConfig.ClearRows());