Link to home
Start Free TrialLog in
Avatar of Edward van Nijmweegen
Edward van NijmweegenFlag for Netherlands

asked on

How to access the property of a child usercontrol form in c# or vb.net

Hello,

I have a windows form with a panel wich include a usercontrol form.
Now i have to run some code on the main (parent) form, that checks the value of a property on the child form(usercontrol in panel).

I have created a public readonly property on the usercontrol, but when i try to read this i can't get the value.

I also get the error message "Conversion from string "" to type 'Integer' is not valid." on line  If uc.rl1 = True.

Property on usercontrol:
 Public ReadOnly Property rl1() As Boolean
        Get
            Dim r As Integer
            r = CInt(Me.txtRowIndex.Text)
            If r > -1 Then
                Return DGTimeTable.Item(4, r).Value
            Else
                Return False
            End If
        End Get
      End Property

Open in new window


Code on mainform that should read this property:
 Dim buffer As Byte()
            ReDim buffer(2)
            Dim uc As ucTestform = New ucTestform
            uc = Me.ucPanel.Controls.Find("ucTestform", False)(0)
          
            If uc.rl1 = True Then buffer(0) = buffer(0) Or 128 Else buffer(0) = buffer(0) And 127
         

Open in new window


Thanks in advance.

Edward
SOLUTION
Avatar of Valliappan AN
Valliappan AN
Flag of India 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
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America 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 Edward van Nijmweegen

ASKER

I was stupid. The rowindex was empty, so it couldn't convert it to an integer. And the combinatin with boolean.parcse etc...  did the trick.

Thanks a lot both of you.

Regards,

Edward