简单的保存设置 [英] Simple save settings
问题描述
这是我第一次处理设置。
我有一个简单的应用程序,可以以标准(小)尺寸显示,当选中mnuStandard或其高级(大)尺寸时,检查mnuAdvanced时。
如何保存用户选择的设置。
我去了礼仪----->设置
string1:mnuStandard boolean false
string2:mnuAdvanced boolean false
这两个菜单项的代码。(到现在为止我无法设置代码)
并提前感谢您的支持你的帮助。
Hi,
It''s the first time I deal with settings.
I have a simple application which could be displayed in its standard (small) size, when mnuStandard is checked or in its advanced (large) size, when mnuAdvanced is checked.
How to save the setting the user had chosen.
I went to proprieties----->settings
string1:mnuStandard boolean false
string2:mnuAdvanced boolean false
This the code for the two menu items.(until now I''m unable to code for settings)
And thank you in advance for your help.
Private Sub mnuStandard_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuStandard.Click
If sender Is Me.mnuStandard Then
Me.mnuStandard.Checked = True
Me.Width = 500
Me.Height = 500
Me.mnuAdvanced.Checked = False
End If
Private Sub mnuAdvanced_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuAdvanced.Click
If sender Is Me.mnuAdvanced Then
Me.mnuAdvanced.Checked = True
Me.Width = 600
Me.Height = 600
Me.mnuStandard.Checked = False
end if
推荐答案
这是使用Windows注册表执行此操作的简单方法:
1 。在程序的表单加载事件中检索设置
Here is a simple way to do it using the Windows Registry:
1. In the program''s Form Load Event retrieve the settings
Dim strMenuType As String = CSTR(Microsoft.VisualBasic.Interaction.GetSetting("MyAppName", "Menu", "Type", "Standard")) '' Default to Standard
If strMenuType = "Standard" Then
Me.mnuStandard.Checked = True
Me.Width = 500
Me.Height = 500
Me.mnuAdvanced.Checked = False
Else
Me.mnuAdvanced.Checked = True
Me.Width = 600
Me.Height = 600
Me.mnuStandard.Checked = False
End If
2 。当用户在程序菜单中选择选项时保存设置
2. Save the settings when the user selects the option in the program''s menu
Private Sub mnuStandard_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuStandard.Click
Me.mnuStandard.Checked = True
Me.Width = 500
Me.Height = 500
Me.mnuAdvanced.Checked = False
Microsoft.VisualBasic.Interaction.SaveSetting("MyAppName", "Menu", "Type", "Standard")
End Sub
Private Sub mnuAdvanced_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuAdvanced.Click
Me.mnuAdvanced.Checked = True
Me.Width = 600
Me.Height = 600
Me.mnuStandard.Checked = False
Microsoft.VisualBasic.Interaction.SaveSetting("MyAppName", "Menu", "Type", "Advanced")
End Sub
这篇关于简单的保存设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!