简体   繁体   English

如果前两列包含数据,则禁用数据网格视图的第三列

[英]disable third column of data grid view if first two column having data

I am working on windows form.. 我正在使用Windows窗体。
I have a data grid view say(3 column).i want to disable third column if i don't have data in first, two columns. 我有一个数据网格视图say(3列)。如果我在第一两列中没有数据,我想禁用第三列。
if i have data in first two columns then third column should be enable.. 如果我在前两列中有数据,则应启用第三列。

my data grid view like thise 我的数据网格视图像这样

在此处输入图片说明

if first two column have some data then i have to enter some id in third column.other wise i dont want to allow enter id in third column 如果前两列有一些数据,那么我必须在第三列中输入一些ID。否则,我不想允许在第三列中输入ID
how i can do this ? 我该怎么做?
any help is very appreciable? 有什么帮助是非常明显的吗?

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;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM