日期:2014-05-18  浏览次数:20769 次

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类型的,又没办法让他转换啊??????