winform datagridview 根据条件来判断某一个单元格的值是否为可编辑

1.
根据条件来判断某一个单元格的值是否为可编辑,关键是datagridview中的CellBeginEdit

 

ExpandedBlockStart.gif CellBeginEdit
 1     private   void  dataGridView1_CellBeginEdit( object  sender, DataGridViewCellCancelEventArgs e)
 2          {
 3              var dgv  =  (DataGridView)sender;
 4               string  name  = " wtq " ;
 5               string  cellText  =  Convert.ToString(dgv[ 0 ,e.RowIndex].Value) ;
 6               if  (cellText.Equals(name))
 7              {
 8                  e.Cancel  =   true ;
 9              }
10            
11          }

 

 用途:可以根据单元格的值来判断该单元格是否可编辑。或者可以根据其他单元格的取值来判断该单元格是否可以编辑

 

 

你可能感兴趣的:(winform datagridview 根据条件来判断某一个单元格的值是否为可编辑)