【发布时间】:2014-09-16 05:51:33
【问题描述】:
我正试图弄清楚一旦从单选按钮的选项中选择了重置我的 Windows 窗体应用程序的选项。例如:。
因此,一旦选择“是”,程序就会重置。这是我一直在尝试的。
private void EndOptions() {
if (anotheryes.Checked) {
RestartForm();
}
if (anotherno.Checked) {
//todo
}
}
restartform方法就是:
private void RestartForm() {
Application.Restart();
Application.ExitThread();
}
现在,这只有在我再次按下“计算比率”按钮时才有效。单击后,应用程序将重新启动。我想要它,只需单击“是”单选按钮即可重置。
按钮背后的逻辑如下:
private void DisplayLogic() {
double height = 0, waist = 0;
if (WaistNumericCheck(out waist) && HeightNumericCheck(out height)) { //check if input is numeric, if true, move on to next check
if (CheckDimensionHeight(height) == true && CheckDimensionsWaist(waist) == true) { //check if dimensions are higher than the lower limits, if BOTH true, move on the next
ShowResult(height, waist); //shows results
DisableInputs(); //disables inputs while results are being shows
AnotherGroupBoxVisible();//makes the restart selection groupbox visible
EndOptions(); //check to see which option is selected
}
}
}
任何提示/帮助将不胜感激,谢谢!
【问题讨论】:
-
您选择了惰性选项。只需编写一些代码即可使您的应用程序处于适当的状态。如果您必须设置或重置一些变量,请执行此操作。完全重新启动应用程序只是一个技巧。
标签: c# forms application-restart