读书人

datagridview 中类型转换,该如何解决

发布时间: 2012-07-05 07:59:18 作者: rapoo

datagridview 中,类型转换
winform 中,datagriview现在有一列 是属于 button 类型的, 我如何让这列的值变的不可用啊。

if (dsclient.Tables[0].Rows[shu]["ClientQQ"].ToString() == "")
{
Button b = (Button)dgvClient.Rows[shu].Cells["客户QQ聊天"];
b.Enabled = false;
}

我现在这样写是不行的,但怎样才能让符合条件的button不能用啊

[解决办法]

探讨
winform 中,datagriview现在有一列 是属于 button 类型的, 我如何让这列的值变的不可用啊。

if (dsclient.Tables[0].Rows[shu]["ClientQQ"].ToString() == "")
{
Button b = (Button)d……

[解决办法]
你的思路错误了,既然DataGridViewButtonCell不是button类型,你就没法转,其实你要解决的问题是不让这个按钮按下,或者不显示按钮,

探讨

引用:
dgvClient.Rows[shu].Cells["客户QQ聊天"]不是button类型,而是DataGridViewButtonCell,



你说的我明白啊,问题是我要将DataGridViewButtonCell 类型的转换成 button类型的,又没办法让他转换啊??????

读书人网 >C#

热点推荐