Form Container

  • Thread starter Thread starter shachar
  • Start date Start date
S

shachar

hi all.
in form1 i wrote:
dim MyForm2 as form=new form2

now i want to insert data to the property "id" of form2.
i wrote:
MyForm2.Id=3
but i get an error saying "Id" is not a member of
system...
how can i address the property of form2, contained by
form1?
 
Shachar,

Did you make on form 2 a friend or public field "ID"?
The most simple one is

Friend ID as Integer

in top of your form2 direct beneath the designer created code.

I hope this helps?

Cor
 
Hi Shachar

I'm assuming you've added a property called Id to Form2...

The problem could be your declaration (if you have Option Strict On).

You have declared

Dim MyForm2 As Form = New Form2

This means that you have a Form reference, not a Form2 reference - with
Option Strict On, as Form does not have an Id property, you can't access it -
even though the MyForm2 object has an Id property.

Two solutions:

1. Change the declaration to
Dim MyForm2 As Form2 = New Form2
or
Dim MyForm2 As New Form2
(Identical performance)

or turn Option Strict Off...slower, because now reflection will be used to
look up the property and set the value.

HTH

Nigel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top