ActiveForm query (C#)

denz

Newcomer
Joined
May 26, 2003
Messages
2
ActiveForm query

Hi,

I have 2 radiobuttons (apart from some other controls) on a form and need to access the value (checked or unchecked) of the same from another class.

I obtain a reference to the said form using ActiveForm and then using myForm.ActiveForm.Controls get access to all controls in the form.

However, I can't seem to access the checked value of the control (for the radiobuttons). During compile it return an error stating that Checked is not a property of Controls collection.

Any way to get around this ?

Thanks for your time.
Denzil
 
The best way is to just pass an instance of the form to your procedure, like so:

Visual Basic:
MyProc(Me)

'And in your class...
Public Sub MyProc(f As Form1)
    f.MyCheckBox.Checked = True
End Sub
 
Passing the form reference solved it. Thanks

Hi Divil,

Thanks for your reply. Solved the same by passing the form as reference.

Cheerz,
Denz
 
Back
Top