c#的winform里,找不到类型或命名空间名称datagriditem的问题

来源:百度知道 编辑:UC知道 时间:2024/06/03 12:38:16
c#的winform里,显示这2行错误,
DataGridItem ob = (DataGridItem) btnSender.Parent.Parent;
int ErrorVal = rasDisplay.Connect(ob.Cells[1].Text);

错误都是:找不到类型或命名空间名称datagriditem是否缺少using指令或程序集引用

程序段为:
private void button1_Click(object sender, System.EventArgs e)
{
RAEDisplay rasDisplay = new RAEDisplay();
Button btnSender = (Button) sender;
DataGridItem ob = (DataGridItem) btnSender.Parent.Parent;

int ErrorVal = rasDisplay.Connect(ob.Cells[1].Text);

if(ErrorVal != 0)
{
Console.WriteLine(ErrorVal);
}
else
{
Console.WriteLine(ErrorVal);
}
}
谢谢 张琎, 只是程序是从 webform 里移植到 winform 里才出现这个问题的,原来没问题,现在怎么改呢?

DataGridItem 是要引用System.Web.UI.WebControls 命名空间的,即:
using System.Web.UI.WebControls;

而且有一点很重要DataGridItem 只能用在WEB里面,WINFORM里是不能用的,因为WINFORM里根本就没有System.Web.UI.WebControl这个命名空间