DevExpress datagridview多选实现

C# 2022-02-11 15:47:30

DevExpress datagridview多选实现

private void gridView1_Click(object sender, EventArgs e)
{
if (DevControlHelper.ClickGridCheckBox(this.gridView1, "Check", m_checkStatus))
{
m_checkStatus = !m_checkStatus;
}
}

private void gridView1_CustomDrawColumnHeader(object sender, DevExpress.XtraGrid.Views.Grid.ColumnHeaderCustomDrawEventArgs e)
{
if (e.Column != null && e.Column.FieldName == "Check")
{
e.Info.InnerElements.Clear();
e.Painter.DrawObject(e.Info);
DevControlHelper.DrawCheckBox(e, m_checkStatus);
e.Handled = true;
}
}
void gridView1_DataSourceChanged(object sender, EventArgs e)
{
GridColumn column = this.gridView1.Columns.ColumnByFieldName("Check");
if (column != null)
{
column.Width = 80;
column.OptionsColumn.ShowCaption = false;
column.ColumnEdit = new RepositoryItemCheckEdit();
}
}