如何在c#中使用应用程序设置保存对Windows窗体的更改 [英] how to save changes to a windows form in using application settings in c#

查看:115
本文介绍了如何在c#中使用应用程序设置保存对Windows窗体的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个表单,form1和form2。 form1是主窗体,包含3个按钮和3个menustrip items.form 2引用了form1并包含2个checkboxes.Checkbox1选中时禁用form1上的按钮和menustrip项目以及复选框2时启用form1上的按钮和menustrip项目。

i想要保存更改,以便下次关闭后打开应用程序我应该看到更改。

请如何使用应用程序保存对应用程序的更改c#中的设置

i have 2 forms,form1 and form2. form1 is the main form and contains 3 buttons and 3 menustrip items.form 2 has been reference to form1 and contains 2 checkboxes.Checkbox1 when checked disable the buttons and menustrip items on form1 and checkbox2 when checked enable the buttons and menustrip items on form1.
i want to save the changes so that the next time i open the application after closing i should see the changes.
please how do i save the changes to the application using application settings in c#

推荐答案

1.您应该为控制用户界面选项的每个复选框创建属性;你可以通过在Visual Studio中添加/编辑项目属性来做到这一点。



2.在复选框点击事件中你应该设法更改属性值并保存其状态(true或false)使用以下方法进入应用程序设置: Properties.Settings.Default.Save()



3.在加载事件中,您应该读取属性值(使用相同的对象: Properties.Settings.Default 并启用或禁用表单中的工作人员。
1.You should create properties for each checkbox that controls the user interface options; you could do this by adding/editing in Visual Studio the project properties.

2.On checkbox click event you should manage to change the property value and to save its state (true or false) into the application settings by using: Properties.Settings.Default.Save()

3.On from Loading event you should read the properties values (by using the same object: Properties.Settings.Default ) and enable or disable functionaries from your forms.


这篇关于如何在c#中使用应用程序设置保存对Windows窗体的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆