【问题标题】:disable third column of data grid view if first two column having data如果前两列有数据,则禁用数据网格视图的第三列
【发布时间】:2014-02-17 05:48:39
【问题描述】:

我正在处理 Windows 窗体..
我有一个数据网格视图说(3 列)。如果我在第一列两列中没有数据,我想禁用第三列。
如果我在前两列中有数据,则应启用第三列..

我的数据网格视图像这样

如果前两列有一些数据,那么我必须在第三列中输入一些 id。否则我不想允许在第三列中输入 id
我该怎么做?
任何帮助都非常显着?

【问题讨论】:

    标签: c# winforms datagridview


    【解决方案1】:
    String Cell1=dataGridView1.Rows[0].Cells[0].Value.ToString();
    String Cell2=dataGridView1.Rows[0].Cells[1].Value.ToString();
    
    if(String.IsNullOrWhiteSpace(Cell1) && String.IsNullOrWhiteSpace(Cell2))
    {
    dataGridView1.Rows[0].Cells[2].ReadOnly = true;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-11
      相关资源
      最近更新 更多