|
-
Dec 29th, 2004, 07:16 AM
#1
Thread Starter
Lively Member
accessing vars from different form
Hi guys, going crazy with this:
When I want to open a new form I do something like:
Dim newform as fromclass1 = new formclass1
newform.show()
if I want to change a textbox in newform I can do:
newform.textbox.text= "nice"
Now, what if I want to access a public element (such as a combobox or textbox) in the original form (from where newform opened) from the form newform?
I just want to do the same I did above to access newform.textbox but inverse. The form from where newform was called already exists (obviously) and it was called firstform, but doing, from newform:
firstform.textbox doesn't work,
not even if I declare firstform as public.
Hope I explained it clearly enough.
Thanks
Last edited by nacho2; Jan 4th, 2005 at 08:48 AM.
-
Dec 29th, 2004, 07:27 AM
#2
Re: accessing vars from different form
 Originally Posted by nacho2
firstform.textbox doesn't work,
not even if I declare firstform as public.
How did you declared it public?
Regards
Jorge
"The dark side clouds everything. Impossible to see the future is."
-
Dec 29th, 2004, 07:36 AM
#3
Thread Starter
Lively Member
Re: accessing vars from different form
In the form where firstform opens from instead of writing:
Dim firstform as formclass2 = new formclass2
I did:
Public firstform... same thing
The most difficult thing about this problem I think it is explaining it!
-
Dec 29th, 2004, 07:48 AM
#4
Re: accessing vars from different form
Declare it has
Code:
Public firstform as new firstform
On firstform load event put this
on firstform closing event put this
Code:
firstform = nothing
Regards
Jorge
"The dark side clouds everything. Impossible to see the future is."
-
Dec 29th, 2004, 08:09 AM
#5
Thread Starter
Lively Member
Re: accessing vars from different form
Don't quiet get it!
I got a form which opens when I execute the application, lets call it firstfirstform, and it has the following code:
Public firstform as formclass2 = new formclass2
later on...
event click:
firstform.show()
Now in firstform got almost the same:
Public newform as formclass1 = new formclass1
later on...
newform.show()
Now from newform I need to access a textbox which is in firstform, I try to do firstform.textbox.text=...
but i says I haven't declared firstform.
I've tried to use the lines you told me but don't seem to work.
-
Dec 29th, 2004, 09:04 AM
#6
Thread Starter
Lively Member
Re: accessing vars from different form
Can I handle an event of newform from firstform?
instead of this:
VB Code:
Private Sub firstform_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.closed
writing something like this:
VB Code:
Private Sub newform_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles newform.closed
That above doesn't work but maybe the idea is good.
Don't know I'm stuck.
Which event triggers when you go back to a window which never closed but had a new window opened on top? That could help too, I tried gotFocus and Activated and gotFocus doesn't seem to work and activated only triggers the first time you open the window.
thanks for your help
-
Jan 4th, 2005, 08:47 AM
#7
Thread Starter
Lively Member
Re: accessing vars from different form
ok got it, i used vars and functions as public shared and that solved my problem.
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
|