本文介绍了如何避免在C#windows窗体应用程序中打开表单的多个实例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



我写了一个程序,里面有一个关于按钮,按下主窗体上的about按钮会打开另一个表格,提供一些关于程序,然而,单击关于按钮将使这种形式的另一个实例,我该如何避免它?



我的代码是:

Hello,

I have write a program which has an About button, pressing the about button on the main form will open another form which gives some information about the program, however, clicking the about button will make another instances of such form, how can I avoid it?

my code is:

private void aboutToolStripMenuItem1_Click(object sender, EventArgs e)
{
    FormAbout formAbout = new FormAbout();
    formAbout.Show();
}





提前致谢

AM



Thanks in advance
AM

推荐答案

private void aboutToolStripMenuItem1_Click(object sender, EventArgs e)
{
    FormAbout formAbout = new FormAbout();
    formAbout.ShowDialog();
}



这篇关于如何避免在C#windows窗体应用程序中打开表单的多个实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 21:35