Devexpress WinForm GridControl实现单元格可编辑状态更改

之前做项目的时候,需要实现这样的功能。在gridcontrol中,根据是否修改(checkbox)列的选中和未选中状态来联动另外一列的编辑状态。实现如下:

 private void gridView1_ShowingEditor(object sender, CancelEventArgs e)
 {
            try
            {
                DataRow row = gridView1.GetDataRow(this.gridView1.FocusedRowHandle);
                if (row != null)
                {
                    //当modifyflag的值为0时(是否修改列未选中时),设置当前行的第三列的单元格不可编辑
                    if (Convert.ToInt32(row["modifyflag"]) == 0 && gridView1.FocusedColumn.AbsoluteIndex == 3)
                    {
                        e.Cancel = true;
                    }
                }
            }
            catch (Exception)
            {

                throw;
            }
  }

 

posted @ 2017-09-12 17:12  微笑着微笑  阅读(1864)  评论(1编辑  收藏  举报