如何在C#中禁用datagridview中的某个按钮 [英] How to disable some button in datagridview in C#
本文介绍了如何在C#中禁用datagridview中的某个按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个DGV和我所有列的类型是DataGridViewButtonColumn,我想禁用一些按钮的
喜欢
row [1] .cell [1]或者别的什么
我尝试了什么:
if (dataGridView1.Rows [ 0 ]。单元格[ 0 ]。值== null )
{
/ // 禁用该按钮
}
解决方案
< blockquote> null
这里不是一个好的测试 - 如果单元格值是 null
它不是一个按钮!
但即便如此,也没有内置的方法来禁用它: https://msdn.microsoft.com/en-us/library/ms171619(v = vs.110).aspx [ ^ ]解释,并说明如何操作。
请参考如何:在Windows窗体中禁用按钮列中的按钮DataGridView控件
[ ^ ]
这里是
this .button1.disable;
I Have A D.G.V And All Of My Column's Type Is DataGridViewButtonColumn , I Want To Disable Some Of That Button's
Like
row[1].cell[1] or somthing else
What I have tried:
if (dataGridView1.Rows[0].Cells[0].Value == null)
{
/// disable that button
}
解决方案
null
is not a good test here - if the cell value isnull
it's not a button!
But even then there is no built in way to disable it: https://msdn.microsoft.com/en-us/library/ms171619(v=vs.110).aspx[^] explains, and shows how to do it.
Please refer How to: Disable Buttons in a Button Column in the Windows Forms DataGridView Control
[^]
here is it
this.button1.disable;
这篇关于如何在C#中禁用datagridview中的某个按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文