473,386 Members | 1,644 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Cross form control reference

I have been at this for over a month and have finally broke down and decided
to post having exhausted all other resources.
I have tried all the methods of talking to controls on different forms.

I have tried ...
dim _Form1 as New Form1()
using properties in the globals file
Using imports in the top of my code.

All of which have failed. They do not give errors. They just don't change
anything. I need to be able to command the Form1 with Form2, like changing
focus and enabling.

Here is my scenario ...

MDIMainForm->Form1->Form2
In MDIMainForm ...
------------------------------------------
Dim _Form1 As New Form1()
_Form1.MdiParent = Me
_Form1.Show()
_Form1 = Nothing
------------------------------------------
In Form 1...
------------------------------------------
Dim _Form2 As New Form2()
_Form2.MdiParent = MDIMainForm.ActiveForm
_Form2.Show()
_Form2 = Nothing
------------------------------------------
In Form 2
------------------------------------------
This is where is have tried to ref Form1
------------------------------------------
Maybe I am launching form2 the wrong way. If I don't make MDIForm the Parent
then Form2 runs wild.
Big FYI .. I need Form2 to be held be the MDIForm and be controlled be
Form1.

Sys Info
Windows XP Pro Sp1
Latest .NET 1.1
Visual Studio.NET

Thanks for any help anyone can give.
Me









Nov 20 '05 #1
4 1116
A lot of people are having this kind of problems, mostly due to the fact
that this was different in VB6. In VB.NET you need a reference to another
form if you want to get data from that form for example. Luckily there is a
very good article on MSDN describing these kind of problems:
http://msdn.microsoft.com/library/en...hworkingwithmu
ltipleformsinvisualbasicnetupgradingtonet.asp
Describes how working with multiple forms has changed from previous editions
of Microsoft Visual Basic and illustrates several key techniques, including
displaying a second form, changing the appearance of another form, and using
a form as a dialog.

If you have more questions, please ask them!

--
Greetz

Jan Tielens
________________________________
Read my weblog: http://weblogs.asp.net/jan
"Larry Tate" <dw********@yahoo.com> wrote in message
news:OR**************@tk2msftngp13.phx.gbl...
I have been at this for over a month and have finally broke down and decided to post having exhausted all other resources.
I have tried all the methods of talking to controls on different forms.

I have tried ...
dim _Form1 as New Form1()
using properties in the globals file
Using imports in the top of my code.

All of which have failed. They do not give errors. They just don't change
anything. I need to be able to command the Form1 with Form2, like changing
focus and enabling.

Here is my scenario ...

MDIMainForm->Form1->Form2
In MDIMainForm ...
------------------------------------------
Dim _Form1 As New Form1()
_Form1.MdiParent = Me
_Form1.Show()
_Form1 = Nothing
------------------------------------------
In Form 1...
------------------------------------------
Dim _Form2 As New Form2()
_Form2.MdiParent = MDIMainForm.ActiveForm
_Form2.Show()
_Form2 = Nothing
------------------------------------------
In Form 2
------------------------------------------
This is where is have tried to ref Form1
------------------------------------------
Maybe I am launching form2 the wrong way. If I don't make MDIForm the Parent then Form2 runs wild.
Big FYI .. I need Form2 to be held be the MDIForm and be controlled be
Form1.

Sys Info
Windows XP Pro Sp1
Latest .NET 1.1
Visual Studio.NET

Thanks for any help anyone can give.
Me








Nov 20 '05 #2
* "Larry Tate" <dw********@yahoo.com> scripsit:
I have been at this for over a month and have finally broke down and decided
to post having exhausted all other resources.

I have tried all the methods of talking to controls on different forms.

I have tried ...
dim _Form1 as New Form1()
using properties in the globals file
Using imports in the top of my code.

All of which have failed. They do not give errors. They just don't change
anything. I need to be able to command the Form1 with Form2, like changing
focus and enabling. [...] ------------------------------------------
Dim _Form2 As New Form2()
_Form2.MdiParent = MDIMainForm.ActiveForm
_Form2.Show()
_Form2 = Nothing


I don't understand the code above. Why do you assign the 'ActiveForm'
property to the 'MdiParent' property?

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #3
Because if I don't set the ActiveForm to the MDI then Form2 is not held
within the MDIForm. It launches outside the MDIForm.I could be doing this
wrong. I dunno.

Am I launching the forms properly? If not why is it wrong.

Also ... Thanks for the reply Jan :)

Thanks,
Larry


"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
* "Larry Tate" <dw********@yahoo.com> scripsit:
I have been at this for over a month and have finally broke down and decided to post having exhausted all other resources.

I have tried all the methods of talking to controls on different forms.

I have tried ...
dim _Form1 as New Form1()
using properties in the globals file
Using imports in the top of my code.

All of which have failed. They do not give errors. They just don't change anything. I need to be able to command the Form1 with Form2, like changing focus and enabling.

[...]
------------------------------------------
Dim _Form2 As New Form2()
_Form2.MdiParent = MDIMainForm.ActiveForm
_Form2.Show()
_Form2 = Nothing


I don't understand the code above. Why do you assign the 'ActiveForm'
property to the 'MdiParent' property?

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #4
Still at the same point. I tried to use this code here from the article ...

Private Shared m_vb6FormDefInstance As Form1
Private Shared m_InitializingDefInstance As Boolean
Public Shared Property DefInstance() As Form1
Get
If m_vb6FormDefInstance Is Nothing OrElse
m_vb6FormDefInstance.IsDisposed Then
m_InitializingDefInstance = True
m_vb6FormDefInstance = New Form1()
m_InitializingDefInstance = False
End If
DefInstance = m_vb6FormDefInstance
End Get
Set(ByVal Value As Form1)
m_vb6FormDefInstance = Value
End Set
End Property
I inserted this in head of my form2 to ref form1.
I tried DefInstance.TextBox.Text = "Test"

And as usual, no error and no change.

Can someone send me a test project that does what I am trying to do?
dw********@yahoo.com

Thanks,
Larry


"Larry Tate" <dw********@yahoo.com> wrote in message
news:OR**************@tk2msftngp13.phx.gbl...
I have been at this for over a month and have finally broke down and decided to post having exhausted all other resources.
I have tried all the methods of talking to controls on different forms.

I have tried ...
dim _Form1 as New Form1()
using properties in the globals file
Using imports in the top of my code.

All of which have failed. They do not give errors. They just don't change
anything. I need to be able to command the Form1 with Form2, like changing
focus and enabling.

Here is my scenario ...

MDIMainForm->Form1->Form2
In MDIMainForm ...
------------------------------------------
Dim _Form1 As New Form1()
_Form1.MdiParent = Me
_Form1.Show()
_Form1 = Nothing
------------------------------------------
In Form 1...
------------------------------------------
Dim _Form2 As New Form2()
_Form2.MdiParent = MDIMainForm.ActiveForm
_Form2.Show()
_Form2 = Nothing
------------------------------------------
In Form 2
------------------------------------------
This is where is have tried to ref Form1
------------------------------------------
Maybe I am launching form2 the wrong way. If I don't make MDIForm the Parent then Form2 runs wild.
Big FYI .. I need Form2 to be held be the MDIForm and be controlled be
Form1.

Sys Info
Windows XP Pro Sp1
Latest .NET 1.1
Visual Studio.NET

Thanks for any help anyone can give.
Me








Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: [Yosi] | last post by:
What I should do to return back the permissin I had in VS2003 , that allowd me to access public methode of one Class from other Thread. I have Class A(FORM) which create new thread (new class B),...
3
by: maffonso | last post by:
Hi guys, I have built a cross reference query (columns is year). I would like to change the caption and adjust others things. The best way would be to wrap the query in a form, but soon 2007 will...
16
MitchR
by: MitchR | last post by:
Hi All; I have a form that contains a textbox control called CPUServicetag (Serial number). My users enter in the CPUServicetag manually. My question is this ... How do I go about creating an...
5
by: nospam | last post by:
Hi all. I have encountered a "Cross-thread operation not valid" error in a test program I created and although I have came up with a solution I don't like the performance of the program. I...
19
by: Coward 9 | last post by:
HI, I saw in an example hello.aspx, there is a <form tagbeing used like <form runat="server> I search all html tag references and could NOT find "runat" attributes for <formtag. which...
1
misscrf
by: misscrf | last post by:
I have a table that acts as a cross reference to related records. No we can't get different data, no we have no control over what we have, we just need to be able to manage what we have been given....
4
by: nospam | last post by:
I have a table that acts as a cross reference to related records. No we can't get different data, no we have no control over what we have, we just need to be able to manage what we have been...
8
by: =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?= | last post by:
I the page knows there was a cross post back. but i can not find the control. (asp.net 3.5) calling page has a master calling control: <asp:Button ID="btnSendAlert" runat="server" Text="Go"...
11
by: Simon van Beek | last post by:
Dear reader, By opening an application I get always the main Access window with the closing cross in the above right corner. Is there a possibility to make this closing cross invisible? ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.