By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,761 Members | 958 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,761 IT Pros & Developers. It's quick & easy.

hiding/showing a form...

P: n/a
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

Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies

P: n/a

try fully qualifying the reference to the control:

Form1.usercontrol1.label.text = "hello, world"
johnb41 wrote:
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


Nov 21 '05 #2

P: n/a
johnb41,

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

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

Kerry Moorman
"johnb41" wrote:
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

Nov 21 '05 #3

P: n/a
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?

*** Sent via Developersdex http://www.developersdex.com ***
Nov 21 '05 #4

P: n/a
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

Nov 21 '05 #5

P: n/a
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.

Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.