|
-
Jul 11th, 2004, 07:48 PM
#1
Thread Starter
Lively Member
Form refrences [Resolved]
Quick question on how to interact between one form and another
if you don't mind me asking.... I open Form2 with this:
Code:
Dim Frm As New Form2()
Frm.ShowDialog()
Now, when Form2 is opened I would like to click a button that will
show the hidden PictureBox that is on Form1 already. My problem
is not knowing how to refrence Form1's PictureBox property.
Code:
Private Button1.Click (ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
'Show the Picture Box that is hidden on Form1
PictureBox1.Visible = True
PictureBox1.Update()
End Sub
Last edited by teamdad; Aug 3rd, 2004 at 01:08 PM.
-
Jul 11th, 2004, 08:00 PM
#2
PowerPoster
Hi,
Hopefully you have remembered to instantiate form1 as public - if you started from a module. Didn't we also once discuss that the modifier property of the controls in form1 should be set to "Public" if you want to refer to them from another form?
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Jul 11th, 2004, 08:55 PM
#3
Thread Starter
Lively Member
For the record: it's not easy for a person with a disability to learn something so complicated as programming. Especially when you are using forums like this, the Internet and scavaging everywhere you can find.
I did find a nice article that explains it all in a clear manner and isn't anything too hard to understand.
Managing Forms VB.NET Style
-
Jul 12th, 2004, 04:35 AM
#4
PowerPoster
Originally posted by teamdad
For the record: it's not easy for a person with a disability to learn something so complicated as programming. Especially when you are using forums like this, the Internet and scavaging everywhere you can find.
I did find a nice article that explains it all in a clear manner and isn't anything too hard to understand.
Managing Forms VB.NET Style
Sorry, I did not mean to be critical. I thought the best way for you to learn was to work it out from your previous posts and I gave you two pointers to possible causes.
Everybody.
Please have a look at the link above. I don't like it. The guy is creating a problem in the way he deals with the forms and then gives a solution for solving it
If a form is instanced properly, there is no problem with hiding it.
What do you guys think?
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Jul 12th, 2004, 06:14 AM
#5
Hyperactive Member
I normally do it like this....
Declare a Public variable in Form2 that will be a reference to Form1
Code:
Public myForm1 as Form1
Then, in the Constuctor in Form2, pass a variable to be assigned to the public variable:-
Code:
Public Sub New(ByRef passedform1 As Form1)
MyBase.New()
myForm1=passedform1
'This call is required by the Windows Form Designer.
InitializeComponent()...........
Then any control on Form1 can be accessed thus:-
Code:
myForm1.Control.Enabled=True
Then in the Disposing event:-
This has always worked for me, but I do not protest it to be efficient! If anybody can let me know of a better way, I'd be grateful.
"I'm Brian and so is my Wife"
-
Jul 12th, 2004, 08:04 AM
#6
PowerPoster
Hi,
That's OK if form1 is not your main form.
Normally a programme consists of a main form from which all the other forms are called. Then your method will simply create a second instance of form1 but there are many ways of cracking an egg - some messier than others
Last edited by taxes; Jul 12th, 2004 at 08:09 AM.
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|