包含类的ArrayList 绑定到DataGrid[z]

private void button2_Click(object sender, System.EventArgs e)
  {
   ArrayList arr = new ArrayList();
   email myEmail = new email();
   myEmail.col1 = "11";
   myEmail.col2 = 22;
   myEmail.col3 = 33;
   arr.Add(myEmail);
   myEmail = new email();
   myEmail.col1 = "1111";
   myEmail.col2 = 2222;
   myEmail.col3 = 3333;
   arr.Add(myEmail);

   this.dataGrid1.DataSource = arr;
  }

  private void button3_Click(object sender, System.EventArgs e)
  {
   ArrayList arr = (ArrayList)this.dataGrid1.DataSource;
   email myEmail = (email)arr[0];
   myEmail.col2 = 444444;
   this.dataGrid1.Refresh();
  }

 

using System;

namespace WindowsApplication3
{
 /// <summary>
 /// email 的摘要说明。
 /// </summary>
 public class email
 {
  private string _col1 = "";
  public string col1
  {
   get
   {
    return _col1;
   }
   set
   {
    _col1 = value;
   }
  }
  private Decimal _col2;
  public Decimal col2
  {
   get
   {
    return _col2;
   }
   set
   {
    _col2 = value;
   }
  }
  private Decimal _col3;
  public Decimal col3
  {
   get
   {
    return _col3;
   }
   set
   {
    _col3 = value;
   }
  }
 }
}



posted @ 2006-10-14 00:22  拒绝潜水的鱼  阅读(391)  评论(0)    收藏  举报