Hi All - I am trying to figure out a user control method on my form to hide/un-hide table layout panels. It seems like the way I am going is just very messy and there has to be a more elegant way of doing this. Right now I have 22 panels on my form. Under each panel I have a checkbox to show or hide it, then I am saving the checkbox state to my.settings. On form load, I am checking my.settings to see if it is "ON" or "OFF" then that will show or hide it. I have not really had too many "user" options in the past and not really sure how this could be handled better. Anyway, this is the mess I have now... Any help or ideas are greatly appreciated.
Code:Private Sub CBST1_CheckStateChanged(sender As Object, e As EventArgs) Handles CBST1.CheckStateChanged If CBST1.CheckState = CheckState.Checked Then My.Settings.ST1 = "OFF" My.Settings.Save() TableLayoutPanel1.Visible = False ElseIf CBST1.CheckState = CheckState.Unchecked Then My.Settings.ST1 = "ON" My.Settings.Save() TableLayoutPanel1.Visible = False End If End Sub Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load If My.Settings.ST1 = "OFF" Then TableLayoutPanel1.Visible = False CBST1.CheckState = CheckState.Unchecked ElseIf My.Settings.ST1 = "ON" Then TableLayoutPanel1.Visible = True CBST1.CheckState = CheckState.Checked End If End Sub




Reply With Quote
