Avatar of Edward van Nijmweegen
Edward van Nijmweegen
Flag 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
.NET ProgrammingC#Visual Basic.NET

Avatar of undefined
Last Comment
Edward van Nijmweegen

8/22/2022 - Mon
SOLUTION
Valliappan AN

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
Fernando Soto

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
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
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck