更新时间:2022-10-29 16:17:21
您可以将其保存为设置中的布尔,您应该检查第一个表单的加载事件。
您的设置文件应该有一个设置,我称之为FirstRun,执行以下步骤:
注意: Scope
可以更改应用程序,如果这是您的应用程序的需要,因为您没有在您的问题中提及。
您的设置文件应如下图所示:
注意:从我的手机写下来,所以我无法编译测试
编辑:从桌面检查代码并添加图像。
Is there an easy way to show an dialog when the program is started for the first time (and only the first time), for some kind of instruction or specifying settings?
You could save it as a bool in your settings and you should check at load event of first form. Your settings file should have a setting that I called "FirstRun" do this with following steps:
Note: The Scope
can be changed to "Application", if that is your application's need, since you didn't mention in your question.
Your Settings file should look like image below:
public void Form1_Load(object sender, EventArgs e)
{
if((bool)Properties.Settings.Default["FirstRun"] == true)
{
//First application run
//Update setting
Properties.Settings.Default["FirstRun"] = false;
//Save setting
Properties.Settings.Default.Save();
//Create new instance of Dialog you want to show
FirstDialogForm fdf = new FirstDialogForm();
//Show the dialog
fdf.ShowDialog();
}
else
{
//Not first time of running application.
}
}
Note: wrote this from my phone, so I couldn't compile to test
Edit: Checked code and added image from desktop.