winform窗体间传值(使用Tag属性)

 Form1中:
   private void Button1_Click(object sender,EventArgs e)
  
  {
	Dataset ds=goods.GetInfoDataSet();
	if(ds.Table[0].Rows.Count>0)
 	{
		Form2 f2=new Form2();
		f2.Tag=ds;
		f2.Show();
	}
  }
 Form2中:
	private void Form2_Load(object sender,EventArgs)
	{
		DataSet ds=(DataSet)this.Tag;
		if(ds.Table[0].Rows.Count>0)
		{
			this.textbox1.text=ds.Table[0].Rows[0][0].ToString();
			this.textBox2.Text=ds.Table[0].Rows[0][1].ToString();
		}		
	}

你可能感兴趣的:(C#)