1

我有一个 FlowLayoutPanel 包含未指定数量的标签,当我双击其中一个时,将出现一个包含TextBoxButton的新表单,代码如下:

foreach (Label lb in FlowLayoutPanel1.Controls)
{
    lb.MouseDoubleClick+=new MouseEventHandler(lb_MouseDoubleClick);
}

private void lb_MouseDoubleClick(object sender, MouseEventArgs e)
{
    NewForm form = new NewForm();
    form.ShowDialog();
    ((Label)sender).Text = ...;//I want get text from TextBox of the NewForm here
}

我想从NewForm 的TextBox中获取 Text 并将 Text 分配给当用户单击 Form 的Button时调用 Form 的对象,我不知道如何使用委托来执行此操作,请帮忙!感谢您阅读本文!

4

1 回答 1

0

To be honest, I think your best bet might be to store the TextBox value in a static variable and simply take the value from there. It'll avoid a lot of complicated work.

That said, I'm not sure of how you've implemented the NewForm class. If you've set that up to have the textbox, or the textbox's value, publicly accessible, you could set it a lot more simply.

于 2012-06-30T00:43:11.153 回答