示例:在应用程序中通过“选项”改变程序中的控制
选择CheckBox,为其Checked属性设置ApplicationSettings。
此操作会
1.自动在Properties中的Settings.settings中添加两个属性值:CloseDocumentPrompt和CloseBatchPrompt。
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool CloseDocumentPrompt {
get {
return ((bool)(this["CloseDocumentPrompt"]));
}
set {
this["CloseDocumentPrompt"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool CloseBatchPrompt {
get {
return ((bool)(this["CloseBatchPrompt"]));
}
set {
this["CloseBatchPrompt"] = value;
}

本文展示了如何在WinForm应用中利用Application Settings功能,通过用户界面更改CheckBox的Checked属性,例如CloseDocumentPrompt和CloseBatchPrompt。设置更改会自动在Properties.Settings中创建属性并更新App.config文件。在Form代码中,我们可以通过这些设置来控制TreeView等控件的行为,如显示保存文档提示。
最低0.47元/天 解锁文章
602

被折叠的 条评论
为什么被折叠?



