Link to home
Start Free TrialLog in
Avatar of PeterFrb
PeterFrbFlag for United States of America

asked on

VB.Net: Changing control properties from outside the form

I sometimes need to set a form's control properties from elsewhere in the code, and I'm getting strange errors whenever I try.   In my situation, I've created a checkbox that I want to change, but while running from withing another form.  Here's a sample of that code:

Dim UseCheck As System.Windows.Forms.CheckBox = MyForm.MyCheckbox
With UseCheck
    .Checked = False
    .Enabled = True
End With

Open in new window


With this code in place, the form won't open.
InvalidOperationException.png
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of PeterFrb

ASKER

Yes, thanks.