Hot can I keep CHECKBOX checked while going from form to form

motti100

Member
Joined
Mar 6, 2005
Messages
19
Programming Experience
1-3
I have 2 forms (Form 1 and Form 2)
In Form 2, I have a few checkboxes. I check them all.
I click on a button that will hide Form 2 and LoadForm 1
Then in Form 1, I click on a button to load Form 2.
The checkboxes are empty....

How can I persist checkbox checked while clicking among forms?
 
Hi Paszt

Thanks for the response. I can still not get it to work.
On Form 1 is a button.
click code - dim f2 as form2
f2.show
On Form 2 is a checkbox and button. (select checkbox)
click code - dim f1 as form1
f1.show

When I click again on Form1 button, form2 loads but checkbox not checked.

I know I am doing wrong here.

Thanks
 
'module added to the project
Friend MyForm1 As Form1

'Form 1's load event:
MyForm1 = Me

form 1's button:
Dim f2 As New Form2
Me.Hide
f2.Show

form 2:
Me.Close
MyForm1.Show
 
In your form1 button click event, each time you DIM a new form2, the checkboxes will be blank if that's the default property setting because you're creating a new form2.

Something along the lines of this should work....

If Form2 IS Nothing then
dim form2 as new .....
end if

Form2.show
 
This is the first problem to overcome when learning Object Oriented Programming.
In VB.NET, forms are now handled as true objects as opposed to VB6 where there was a Default Instance of each form and no need to instantiate a form class.
Here is a good article to read: Multiple Forms in VB.NET. Part 4 - Accessing Controls and Data ...
 
Back
Top