hiding/showing a form...

J

johnb41

I've been frustrating over this now for almost 2 full days. I hope
someone can shed some light...

I have 2 forms, Form1 and Form2. Both these forms contain the same
UserControl.

In my app, i need to hide form2, and show Form1; and also output text
on a label control in the UserControl.

Here's the essentials of the code: (both Form1 and Form2 are "public"
so I can work with them from anywhere in my code)

Form2.hide()
Form1.visible = true
Usercontrol1.Label1.text = "lorum ipsum dolor"

The label text always shows up on Form2. How can I get this text to
show up on Form1?

Thanks!
John
 
G

Guest

johnb41,

If you make the usercontrol on form1 public then you should be able to:

Form1.Usercontrol1.Label1.text = "lorum ipsum dolor"

Kerry Moorman
 
G

Guest

try fully qualifying the reference to the control:

Form1.usercontrol1.label.text = "hello, world"
 
T

Terry Olsen

Speaking of which...

What is Form1.ActiveForm? When I've done something to the form and I
want it to update, there is no Form1.Update. I have to use
Form1.ActiveForm.Update.

If I qualify it as Form1, isn't it by default the form that will receive
the actions I'm assigning?
 
J

johnb41

Thanks! Fully qualifying the path to the usercontrol solved the
problem. I have other related problems, but i think fully qualifying
the path will fix them also. Thanks so much!

John
 
G

Guest

No problem.

Also, I realized later I should have also said in vb.net, you have to
dim a form object in your code before you can refer to the controls on
it.

So if you're working with frmA and need to get the data from a control
called txtMyControl on the form called frmB, you need to go:

Dim myval as String
Dim frm as New frmA

myval = frm.txtMyControl.Text

This is different from VB6, in which you can just name the form
directly without explicitly instantiating it first.
 

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

Similar Threads


Top