Re: Leaving Checkbox checked
I'm not sure what the problem is - if you have a form with 5 tab pages, each containing a check box, each tab page's checkbox will retain its value regardless of which tab is displayed.
Can you elaborate?
Re: Leaving Checkbox checked
What you are asking should be the default behavior. The checkbox controls are independent of each other.
I am assuming you are using the TabControl.
Re: Leaving Checkbox checked
Thanks for replies.
Sorry, but what i meant to have said was if i left the form with the tabpages on to another form then back again. I need the checkbox's kept set to what the user selected.
thanks
Work
Re: Leaving Checkbox checked
So long as you don't close down the form it will retain the state of checkboxes. If you are closing the form then you will need to store the values of the checkboxes somewhere and then retrieve them when you re-load the form.
Depending on the nature of the data and the application you could store these values in a database, in the registry, a configuration file or an object in memory.
Re: Leaving Checkbox checked
This is what i have tried but for somereason it does not seem to work.
The code below is how i have done it, not sure if it is correct.
All the variables and data strings are all defined in a Module.vb named Data as most of the forms in my application need to read there values and use any data set in some strings.
'AddControlPanel' is defined in the Module.vb as
Public AddControlPanel As Integer = 0
' Main Form Page
Public Class Tweaks
Inherits System.Windows.Forms.Form
Public Sub Checkstatus()
If AddControlPanel = 1 Then
AddConPanel.Checked = True
End If
End Sub
Public Sub AddConPanel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddConPanel.CheckedChanged
If AddConPanel.Checked = True Then
AddControlPanel = 1
Else
If AddConPanel.Checked = False Then
AddControlPanel = 0
End If
End If
End Sub
End Class
Re: Leaving Checkbox checked
A bit hard to tell just from those snippets, but presumably you are calling the CheckStatus procedure whenever the form is shown? Have you put a breakpoint in that routine to check that the routine is actually being run when you are expecting it to?
Re: Leaving Checkbox checked
That looks reasonable as it is. Is there code in the Load event, or somewhere like that which calls the CheckStatus sub?
Re: Leaving Checkbox checked
Yeah, what Pennsylvania Paul said.
Re: Leaving Checkbox checked
Thanks all, put a call into the load event and now it is working.