Component Question


Well-known member
May 11, 2005
Northern Michigan
Programming Experience
Hello all this was a neat forum and I had to join.

For my first question here I go:

I have a main form that opens other forms. I have a list of check boxes and the ones that are check when a button is pressed that opens all the forms(second forms) that match the check boxes.

When I do that I gray out the check boxes on the main form because i don't want the user to keep opening up the same form (second Form).

When I close the other forms (Second Forms). I want to enable the check boxes on the main form and uncheck the check box.

Now on my second form do I create and instance of the main form,
Dim mainform = new main

mainform.checkbox1.Enable = True
mainform.checkbox1.CheckState = CheckState.Unchecked

I do this in the closed event of the second form.

Well that doesn't get me any where :confused: , I think I am on the right path but it just isn't working. Any suggestions? Anything would be great, Thanks!
Wellcome to the forum ;)

about your Q; You should declare Public boolean variables and check 'em on load events

Add new module and declare new vars:
Public enabledChk As boolean = False
Public checkedChk As boolean = False

the part with closed event is good approach but wrong code:

enabledChk = true 'or false .. depends on that you want to happens when your main form load
checkedChk = true 'also here

then put load event

If checkedChk = False then
checkedChk = true
checkbox1.Enable = True
checkbox1.C[size=2]heckState = CheckState.Unchecked[/size]
End If

Cheers :)

Please do let me know if something isn't working as it should, i will make a demo for you ...
Last edited:
I am going to assume that each CheckBox on your main Form refers to a different type of Form and that you only want one of each type to be open at any one time. Also, I am going to assume that your main Form will remain open while these other Forms are displayed. If these assumptions are correct, I would suggest the following:

In your main Form, declare your child Form as a variable with events:
[color=Blue]Private WithEvents[/color] childForm [color=Blue]As[/color] ChildForm

In the Click event handler for your button, disable and uncheck the CheckBox that corresponds to the child Form, then open the child Form:
[color=Blue]Private Sub[/color] openFormsButton_Click(...) [color=Blue]Handles[/color] openFormsButton.Click
	[color=Blue]If Me[/color].childFormCheck.Checked [color=Blue]Then[/color]
		[color=Blue]Me[/color].childFormCheck.Enabled = [color=Blue]False[/color]
		[color=Blue]Me[/color].childFormCheck.Checked = [color=Blue]False[/color]

		[color=Blue]Me[/color].childForm = [color=Blue]New[/color] ChildForm
	[color=Blue]End If[/color]
[color=Blue] End Sub[/color]

In your main Form, declare a Closed event handler for the child Form and in it re-enable the CheckBox that corresponds to the child Form:
[color=Blue]Private Sub[/color] childForm_Closed([color=Blue]ByVal[/color] sender [color=Blue]As Object[/color], [color=Blue]ByVal[/color] e [color=Blue]As[/color] System.EventArgs) [color=Blue]Handles[/color] childForm.Closed
	[color=Blue]Me[/color].childFormCheck.Enabled = [color=Blue]True[/color]
[color=Blue] End Sub[/color]