-1

我有这个代码:

  private void linkLabel1_LinkClicked_1(object sender, LinkLabelLinkClickedEventArgs e)
  {
      Form8 of = new Form8();
      of.ShowDialog();
  }

该按钮打开我的form8(好)。但是如果我点击两次,表格就会重复,所以我得到了 2 个相同的 form8。

当我第二次单击链接标签时,是否有任何机构知道如何选择(带到前面)form8(如果它已经打开)。谢谢!

4

1 回答 1

0
public class MainForm
{
    // Keep a reference to your popup form here, so you never create more than one instance
    private Form8 of = new Form8();

    private void linkLabel1_LinkClicked_1(object sender, LinkLabelLinkClickedEventArgs e)
    {
        if (of != null && of.IsDisposed)
            of = new Form8();

        // Call Show(), not ShowDialog() because ShowDialog will block the UI thread
        // until you close the dialog.
        of.Show();
        of.BringToFront();
    }
}
于 2014-08-13T20:00:03.153 回答