Multi Forms

  • Thread starter Thread starter Stanley
  • Start date Start date
S

Stanley

Hi all! Supppose I one main form (frmMain), and another one (form2).
All I want to do is that, when I click a button on frmMain, form2 will
show up, and then when I click a button on form2, frmMain's text will
change to XXXX. Things are getting diffrent from vb6!

Regards,
Stanley
 
Stanley said:
Hi all! Supppose I one main form (frmMain), and another one (form2).
All I want to do is that, when I click a button on frmMain, form2
will show up, and then when I click a button on form2, frmMain's
text will change to XXXX.

Form2 is shown modally: Overwrite Showdialog (or add your own function)
returning the value to be displayed in frmMain. Think the OOP way: Define
the purpose and the INs and OUTs and don't care about the environment. Form2
will be usable everywhere no matter who called it.

Form2 is shown modeless: Raise an event and pass the value. Catch it - the
event and the value - in frmMain and use it.
Things are getting diffrent from vb6!

Yes, finally!

Armin
 
Stanley,

If you start form2 from form1 than the only thing you have to do is to tell
before the show

dim frm2 as new form2
frm2.owner = me

Than you can use in form2 something as
me.owner.label1.text = XXXXX

I hope this helps,

Cor
 
Cor Ligthert said:
Stanley,

If you start form2 from form1 than the only thing you have to do is
to tell before the show

dim frm2 as new form2
frm2.owner = me

Than you can use in form2 something as
me.owner.label1.text = XXXXX


Does with work with Option Strict Off? ;-)

Armin
 
Thanks Armin, I want to show up form2 modelessly. You said I can raise
an event and pass the value, but I don't know how to do that! Suppose I
have a text box and a button in form2, each time the button is press,
frmMain's ListView will add 1 item with the text of form2's text box!
Hope you got me, and solve my problem. Many many thanks!
 
Thanks Cor, but I don't seem to have "me.owner.label1.text" even I have
set frmMain's label1's Modifies to "Public"! Thanks! Working with forms
in VB.Net really get me down!!
 
Thanks Cor, but I don't seem to have "me.owner.label1.text" even I have
set frmMain's label1's Modifies to "Public"! Thanks! Working with forms
in VB.Net really get me down!!
 
Thanks Cor, but I don't seem to have "me.owner.label1.text" even I have
set frmMain's label1's Modifies to "Public"! Thanks! Working with forms
in VB.Net really get me down!!
 
Stanley,

Sorry I typed it direct in the message and forget that it has to be casted
to the type.

\\\in form2
DirectCast(Me.Owner, Form1).Label1.Text = "whatever"
///

This should do it.

Cor
 
Thank Armin, Wagner, and especailly Cor! I made it now! "DirectCast" is
what I really need!! I don't ever think that vb.net is so "cruel"!
 

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