|
-
Dec 5th, 2008, 09:56 AM
#1
Thread Starter
Lively Member
Leaving Checkbox checked
Hi.
In my Form i have 5 tabs and each tabpage has some check box,s in them, now what i need to do is that if a check box is check or unchecked and the user goes to another tabpage then back to the first tabpage the checkbox is still checked or unchecked.
How to i achieve this please?
Many Thanks
Worf
Private Sub AddConPanel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddConPanel.CheckedChanged
End Sub
-
Dec 5th, 2008, 10:15 AM
#2
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?
-
Dec 5th, 2008, 10:17 AM
#3
Addicted Member
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.
-
Dec 5th, 2008, 10:30 AM
#4
Thread Starter
Lively Member
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
-
Dec 5th, 2008, 10:35 AM
#5
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.
-
Dec 5th, 2008, 10:46 AM
#6
Thread Starter
Lively Member
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
-
Dec 5th, 2008, 10:59 AM
#7
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?
Last edited by keystone_paul; Dec 5th, 2008 at 11:05 AM.
-
Dec 5th, 2008, 10:59 AM
#8
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?
My usual boring signature: Nothing
 
-
Dec 5th, 2008, 11:00 AM
#9
Re: Leaving Checkbox checked
Yeah, what Pennsylvania Paul said.
My usual boring signature: Nothing
 
-
Dec 5th, 2008, 03:27 PM
#10
Thread Starter
Lively Member
Re: Leaving Checkbox checked
Thanks all, put a call into the load event and now it is working.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|