使用的applicationSettings来存储的WinForms单选按钮选中属性 [英] Using ApplicationSettings to store Checked property for WinForms RadioButtons

查看:159
本文介绍了使用的applicationSettings来存储的WinForms单选按钮选中属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含3单选按钮的WinForms对话框。我使用的applicationSettings 来每种单选控制检验属性绑定,但它没有做什么,我我希望做的事。现在,我必须单击每个单选按钮前两次它被检查,并没有被持久化的单选按钮。

I have a WinForms dialog box that contains 3 radio buttons. I am using ApplicationSettings to bind the Checked property of each of these RadioButton controls, but it doesn't do what I am expecting it to do. Now I have to click each radio button twice before it gets checked and the selected radio button is not being persisted.

有一行code,我需要在窗体关闭,节省了用户设置?执行

Is there a line of code I need to execute when the form is closed that saves the user settings?

如何省去了2倍上点击单选按钮?

How do I eliminate the need for 2x clicking on the radio buttons?

有没有更好的方式来坚持这种类型的用户设置?我有上获取对话框类中的公共属性/设置一个枚举值,在此基础上单选按钮被选中,但我没有看到那个属性绑定到用户设置一个简单的方法。

Is there a better way to persist this type of user setting? I do have a public property on the dialog box class that gets/sets an enum value based on which radio button is checked, but I didn't see an easy way of binding that property to a user setting.

编辑:如果已指定我使用vb.net。我认为, My.Settings 来代替 Properties.Settings

Should have specified that I'm using vb.net. I think that means My.Settings instead of Properties.Settings.

推荐答案

我可以回答你这部分的问题:

I can answer this part of your question:

有一行code,我需要在窗体关闭,节省了用户设置?执行

Is there a line of code I need to execute when the form is closed that saves the user settings?

应用程序设置存储在你的设置类,在属性命名空间。该设置类有一个静态属性称为默认,从而重新presents当前应用程序的设置。因此,在你的主窗体的Closing事件,你可以调用:

Application settings are stored in your Settings class, in the Properties namespace. The Settings class has a static property called Default, which represents the current settings for your application. So in your main form's Closing event, you call:

Properties.Settings.Default.Save();

...保存设置。

... to save the settings.

同样,你也可以去设置使用编程设定的名称: Properties.Settings.Default.MyRadioButtonState (或任何你叫吧)

Likewise you can get to the settings programatically using the setting's name: Properties.Settings.Default.MyRadioButtonState (or whatever you've called it).

这篇关于使用的applicationSettings来存储的WinForms单选按钮选中属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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