Connecting Tech Pros Worldwide Help | Site Map

Forms in general (a simple question)

Allain Bøge
Guest
 
Posts: n/a
#1: Nov 21 '05
It is really a simple question.

Visual Basic .NET (2003)

I create 2 forms (Form1 and Form2)

I create a checkbox in Form1 (checkbox1)
I create a checkbox in Form2 (checkbox1)
I go to Form1 doubleclick on checkbox1 and alters the code

Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles CheckBox1.CheckedChanged
' here begin the alteration
If CheckBox1.Checked = True Then
Form2. ' here begins the problem, i want to set the control in
form2 the same as in form1


End If
End Sub

The question is very simple
Why can i not refer to a control in form2 from form1. there was no problem
in VB6


Chris Dunaway
Guest
 
Posts: n/a
#2: Nov 21 '05

re: Forms in general (a simple question)


You can refer to a control in Form2 but you must have a reference to
Form2 in order to do. How are you creating your reference to Form2?
Somewhere in your code you must have something similar to this:

Dim MyForm2 As New Form2


Then you can access the checkbox on Form2 like this:

MyForm2.Checkbox1.Checked = True

Hope this helps

Chris

Allain Bøge
Guest
 
Posts: n/a
#3: Nov 21 '05

re: Forms in general (a simple question)


YES it helps, i said it vould be simple

THANK YOU

"Chris Dunaway" wrote:
[color=blue]
> You can refer to a control in Form2 but you must have a reference to
> Form2 in order to do. How are you creating your reference to Form2?
> Somewhere in your code you must have something similar to this:
>
> Dim MyForm2 As New Form2
>
>
> Then you can access the checkbox on Form2 like this:
>
> MyForm2.Checkbox1.Checked = True
>
> Hope this helps
>
> Chris
>
>[/color]
Closed Thread