devexpress gridcontrol datatable 中设置一列为bool在gridview会显示为复选框,请问这个复选框有什么事件 20
2个回答
展开全部
需要在gridcontrol控件中触发CellValueChanging事件,为了在全选做批量操作时不遗漏最后一条数据。eg: private void gridView1_CellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
{
DataRowView drv = (DataRowView)this.dsApplyListBindingSource.Current;//当前选择行数据
if (drv != null)
{
if ((bool)drv["IsSelect"] == false)
{
foreach (DataRow dr in this.dsApplyList.DATApplyListStudent.Rows)
{
if (dr["ApplyID"].ToString() == drv["ApplyID"].ToString())
{
dr["IsSelect"] = true;
}
}
}
else if ((bool)drv["IsSelect"] == true)
{
foreach (DataRow dr in this.dsApplyList.DATApplyListStudent.Rows)
{
if (dr["ApplyID"].ToString() == drv["ApplyID"].ToString())
{
dr["IsSelect"] = false;
}
}
}
}
this.dsApplyListBindingSource.EndEdit();
gridControl1.MainView.PostEditor();
this.dsApplyList.DATApplyListStudent.AcceptChanges();//刷新数据集
}
{
DataRowView drv = (DataRowView)this.dsApplyListBindingSource.Current;//当前选择行数据
if (drv != null)
{
if ((bool)drv["IsSelect"] == false)
{
foreach (DataRow dr in this.dsApplyList.DATApplyListStudent.Rows)
{
if (dr["ApplyID"].ToString() == drv["ApplyID"].ToString())
{
dr["IsSelect"] = true;
}
}
}
else if ((bool)drv["IsSelect"] == true)
{
foreach (DataRow dr in this.dsApplyList.DATApplyListStudent.Rows)
{
if (dr["ApplyID"].ToString() == drv["ApplyID"].ToString())
{
dr["IsSelect"] = false;
}
}
}
}
this.dsApplyListBindingSource.EndEdit();
gridControl1.MainView.PostEditor();
this.dsApplyList.DATApplyListStudent.AcceptChanges();//刷新数据集
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询