显示数组中的元素

zhengye6910 2005-06-30 11:12:24
在VS.NET中创建了一个Windows应用程序,在其中添加了一个DataGrid控件、一个Retrieve按钮,通过单击此按钮,如何在DataGrid控件中显示某个数组中的元素?
我已经为数组建立了一个包装类,代码如下:
protected class Item
{
private string m_text;
public Item(string text)
{
m_text=text;
}
public string Text
{
get {return m_text;}
}
}
如何建立一个此类的数组,然后在Retrieve按钮的Click事件处理程序中编写代码在DataGrid中显示数组中的元素??

...全文
113 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
ljwpal 2005-07-01
  • 打赏
  • 举报
回复
对DataGrid绑定数组就行了被
WTaoboy 2005-07-01
  • 打赏
  • 举报
回复
using System.Collections;
class strIndex
{
public string[] stringList=new string[10];
public int this[int index]
{
get
{
return studentList[index];
}
set
{
studentList[index]=value.ToString();
}
}
}
class Test
{
static void Main()
{
StrIndex objIndex = new StrIndex();
//for
objIndex[1] = "Tom";
System.Console.WriteLine(objIndex[1]);
}

}
qpl007 2005-07-01
  • 打赏
  • 举报
回复
Item[] items = new Item[100];
for(int i=0;i<items.length;i++)
items[i] = new Item("xxx");
yang20052008 2005-07-01
  • 打赏
  • 举报
回复
就是,绑定数组
loveyzy 2005-07-01
  • 打赏
  • 举报
回复
直接绑定数组好了,为什么绕弯呢

110,556

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧