我动的添加TextBox、LinkLabel且它们是成组添加
如form1添加时命名为:
textBox01、linkLabel01
textBox02、linkLabel02
textBox03、linkLabel03
....如何当点击LinkLabel时传递对应的TextBox中的文本到form2中?我的代码(摘其中几句)
TextBox Bill = new TextBox();
LinkLabel Memo = new LinkLabel();
...
Memo.Click += new EventHandler(Memo_Click);这是点击时引发事件
void Memo_Click(object sender, EventArgs e)
{ }请前辈详细指点,最好能给测试通过的源码,非常感谢!
如form1添加时命名为:
textBox01、linkLabel01
textBox02、linkLabel02
textBox03、linkLabel03
....如何当点击LinkLabel时传递对应的TextBox中的文本到form2中?我的代码(摘其中几句)
TextBox Bill = new TextBox();
LinkLabel Memo = new LinkLabel();
...
Memo.Click += new EventHandler(Memo_Click);这是点击时引发事件
void Memo_Click(object sender, EventArgs e)
{ }请前辈详细指点,最好能给测试通过的源码,非常感谢!
Button btn = new Button();
LinkLabel link = new LinkLabel();
link.Tag = btn.Text;
点击事件里:
LinkLabel link = (LinkLabel)sender;
link.tag.ToString();//这不就是你要的值?
{
InitializeComponent(); this.DoubleBuffered = true; this.SuspendLayout(); for (int i = 0; i < 10; i++)
{
TextBox txt = new TextBox();
txt.Dock = DockStyle.Top;
txt.Text = txt.Name = String.Format("txt{0}", i); LinkLabel lbl = new LinkLabel();
lbl.Dock = DockStyle.Top;
lbl.Text = lbl.Name = String.Format("lbl{0}", i);
lbl.LinkClicked += (sender, e) => { MessageBox.Show(((sender as LinkLabel).Tag as TextBox).Text); };
lbl.Tag = txt; this.Controls.Add(txt);
this.Controls.Add(lbl);
} this.ResumeLayout();
}