c# new Form 怎样获取不同的实例
有一个Form1Form1fo;fo=newForm1();fo.text="aaa";fo=newform1();fo.text="bbb";我怎么获取不同的窗体?我是...
有一个Form1
Form1 fo;
fo=new Form1();
fo.text="aaa";
fo=new form1();
fo.text="bbb";
我怎么获取不同的窗体?
我是动态在数据库中加载的! 展开
Form1 fo;
fo=new Form1();
fo.text="aaa";
fo=new form1();
fo.text="bbb";
我怎么获取不同的窗体?
我是动态在数据库中加载的! 展开
2个回答
展开全部
using System.Collections.Generic;
private void button1_Click(object sender, EventArgs e)
{
List<Form1> formList = new List<Form1>();
Form1 fo;
fo = new Form1();
fo.Text = "AAAA";
formList.Add(fo);
fo = new Form1();
fo.Text = "BBBB";
formList.Add(fo);
fo = new Form1();
fo.Text = "CCCC";
formList.Add(fo);
Form1 f1;
foreach (Form1 var in formList)
{
if (var.Text == "AAAA")
{
f1 = var;
MessageBox.Show(f1.Text);
var.Text = "ASDFGHJK";
MessageBox.Show(f1.Text);
}
}
}
private void button1_Click(object sender, EventArgs e)
{
List<Form1> formList = new List<Form1>();
Form1 fo;
fo = new Form1();
fo.Text = "AAAA";
formList.Add(fo);
fo = new Form1();
fo.Text = "BBBB";
formList.Add(fo);
fo = new Form1();
fo.Text = "CCCC";
formList.Add(fo);
Form1 f1;
foreach (Form1 var in formList)
{
if (var.Text == "AAAA")
{
f1 = var;
MessageBox.Show(f1.Text);
var.Text = "ASDFGHJK";
MessageBox.Show(f1.Text);
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询