zoukankan      html  css  js  c++  java
  • winform datagridview 如何设置当首列填写后,其他列才可以填写。

    1,主要利用CellBeginEdit来来判断。

      如果首列为 空,则其他列不能编辑。如果首列不为空,其他列才可以编辑。 因为这有涉及到数据车存储

    代码如下:

    View Code
     1    private void dataGridView1_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
     2         {
     3             var dgv = (DataGridView)sender;
     4             int columnIndex = e.ColumnIndex;
     5             string firstCellValue =Convert.ToString(dgv[0,e.RowIndex].Value);
     6 
     7             if (columnIndex == 0)
     8             {
     9                 e.Cancel = false;
    10             }
    11             else
    12             {
    13                 if (firstCellValue.Equals(string.Empty))
    14                 {
    15                     e.Cancel = true;
    16                 }
    17             }
    18          
    19           
    20         }
  • 相关阅读:
    jdk与jre安装之后的名字
    手机用笔记本上网
    Django简易安装
    python 结巴分词
    Elasticsearch shield权限管理详解
    nginx配置初步
    linux 使用 rz 和 sz 命令
    eclipse 鲜为人知的调试技巧,你用过多少
    HDOJ 题目3555 Bomb(数位DP)
    Ubuntu1204 vim中文乱码解决方法
  • 原文地址:https://www.cnblogs.com/moss_tan_jun/p/2171210.html
Copyright © 2011-2022 走看看