Save checkbox Settings  
Author Message
Shady9399





PostPosted: Visual Basic Express Edition, Save checkbox Settings Top

HI again

how can i save checkbox settings

for example: default configuration is, if cehckbox is uncheked than program will initialize normaly, if is checked than will initialize minimized.

Thanks ;P




Visual Studio Express Editions7  
 
 
ahmedilyas





PostPosted: Visual Basic Express Edition, Save checkbox Settings Top

There are many ways.

you can save it into an Xml configuration file, then read the value back at runtime/startup and act upon the value or save it in your settings (My.Settings)

I've never used My.Settings but take a look at msdn.microsoft.com in the search box ;-)



 
 
Shady9399





PostPosted: Visual Basic Express Edition, Save checkbox Settings Top

And can you give me any example

Thanks!!!



 
 
Tall Dude





PostPosted: Visual Basic Express Edition, Save checkbox Settings Top

'Create a setting called 'cb1'

'(Double click on the solution explorer window, 'My project')

'Find the 'settings' tab.

'Name = cb1, Type = Boolean, Scope = user, Value = False

'On a form with 2 buttons:

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

' chk the box

Me.CheckBox1.Checked = True

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

' unchk the box

Me.CheckBox1.Checked = False

End Sub

Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing

My.Settings.cb1 = Me.CheckBox1.Checked

End Sub

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Me.CheckBox1.Checked = My.Settings.cb1

End Sub

End Class



 
 
Shady9399





PostPosted: Visual Basic Express Edition, Save checkbox Settings Top

Thanks Dude

!!!