none
check box through show /hide button

    Question

  • dear sir
    i have one check box and one button.when i open form above button is hide. if i tick the check box and close the form and when i re open form i want to display above button please help me how to do it.
    thank you
    wansa
        Public Class Form1
            Dim settings As New My.MySettings
            Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
                If My.Settings.check = True Then
                    Button1.Show()
                Else
                    Button1.Hide()
                End If
                My.Settings.Save()
            End Sub
            Private Sub CheckBox1_CheckStateChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckStateChanged
                If CheckBox1.CheckState = CheckState.Checked Then
                    My.Settings.check = True
                Else
                    My.Settings.check = False
                End If
                My.Settings.Save()
            End Sub
        End Class

    Monday, April 3, 2017 3:58 PM

Answers

  • Hi

    This works. I have a setting called Check in the My.Settings, set up via the Project->Properties->Setting, of type Boolean.

    ' set up a My.Settings.Check via the
    ' Project->Properties->Settings
    Option Strict On
    Option Explicit On
    Option Infer Off
    Public Class Form1
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As EventArgs) Handles MyBase.Load
            Button1.Visible = My.Settings.Check
        End Sub
        Private Sub CheckBox1_CheckStateChanged(ByVal sender As Object, ByVal e As EventArgs) Handles CheckBox1.CheckStateChanged
            My.Settings.Check = Not My.Settings.Check
            Button1.Visible = My.Settings.Check
        End Sub
    End Class
    


    Regards Les, Livingston, Scotland

    • Proposed as answer by Cor LigthertMVP Monday, April 3, 2017 5:18 PM
    • Marked as answer by njhwansa Monday, April 3, 2017 11:45 PM
    Monday, April 3, 2017 4:19 PM
  • Dear Sir

    Thank you very much my problem was solved.it is work 100%. i don't know how  to thank you.

     Thank you for your time sir. Really appreciate your help.

    thank you again

    wansa.

    • Marked as answer by njhwansa Monday, April 3, 2017 11:45 PM
    Monday, April 3, 2017 11:44 PM

All replies

  • Hi

    This works. I have a setting called Check in the My.Settings, set up via the Project->Properties->Setting, of type Boolean.

    ' set up a My.Settings.Check via the
    ' Project->Properties->Settings
    Option Strict On
    Option Explicit On
    Option Infer Off
    Public Class Form1
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As EventArgs) Handles MyBase.Load
            Button1.Visible = My.Settings.Check
        End Sub
        Private Sub CheckBox1_CheckStateChanged(ByVal sender As Object, ByVal e As EventArgs) Handles CheckBox1.CheckStateChanged
            My.Settings.Check = Not My.Settings.Check
            Button1.Visible = My.Settings.Check
        End Sub
    End Class
    


    Regards Les, Livingston, Scotland

    • Proposed as answer by Cor LigthertMVP Monday, April 3, 2017 5:18 PM
    • Marked as answer by njhwansa Monday, April 3, 2017 11:45 PM
    Monday, April 3, 2017 4:19 PM
  • Dear Sir

    Thank you very much my problem was solved.it is work 100%. i don't know how  to thank you.

     Thank you for your time sir. Really appreciate your help.

    thank you again

    wansa.

    • Marked as answer by njhwansa Monday, April 3, 2017 11:45 PM
    Monday, April 3, 2017 11:44 PM