473,397 Members | 1,969 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,397 software developers and data experts.

Closing Winforms

Hi all,

I am running into an issue trying to close a form from another form.

I have a main form called MainForm.

A child form is opened in the MainForm as follows:
Dim Form2 As New Form2
Form2.MdiParent = Me
Form2.Show()

Now from Form2 I am opening another form as follows:
Dim Form3 As New Form3
Form3.MdiParent = Me.MdiParent
Form3.Show()

Form3 has 1 button that when pressed I want it to close Form2.
Form3 has another button when pressed I want it to return the focus to form2.

Don't know why I am having problems with this, doesn't seem like a
compicated thing to do. Any ideas?

Thanks in advance.

--
Kevin
Jul 21 '05 #1
3 1979
I forgot to put another question in my original post.

I was wondering if there was a way to access functions on form2 from form3.

For example, when a button is clicked on form3, some action is performed on
form2, like a datagrid refresh for instance.

Thanks again.

"ksedran" wrote:
Hi all,

I am running into an issue trying to close a form from another form.

I have a main form called MainForm.

A child form is opened in the MainForm as follows:
Dim Form2 As New Form2
Form2.MdiParent = Me
Form2.Show()

Now from Form2 I am opening another form as follows:
Dim Form3 As New Form3
Form3.MdiParent = Me.MdiParent
Form3.Show()

Form3 has 1 button that when pressed I want it to close Form2.
Form3 has another button when pressed I want it to return the focus to form2.

Don't know why I am having problems with this, doesn't seem like a
compicated thing to do. Any ideas?

Thanks in advance.

--
Kevin

Jul 21 '05 #2
create a holder class

public class AllForms

public Form1 as form1
public Form2 as form2

End class

put this code on each of the form :

private Forms as AllForms

now when you try to create the form add one more line..

Dim 2ndForm As New Form2
2ndForm.MdiParent = Me
Forms.Form2 = 2ndForm
2ndForm.Show()

you can Forms.Form2.Close()
so you can access Forms.Form2.MethodInForm2

do the same in form 1..
"ksedran" wrote:
I forgot to put another question in my original post.

I was wondering if there was a way to access functions on form2 from form3.

For example, when a button is clicked on form3, some action is performed on
form2, like a datagrid refresh for instance.

Thanks again.

"ksedran" wrote:
Hi all,

I am running into an issue trying to close a form from another form.

I have a main form called MainForm.

A child form is opened in the MainForm as follows:
Dim Form2 As New Form2
Form2.MdiParent = Me
Form2.Show()

Now from Form2 I am opening another form as follows:
Dim Form3 As New Form3
Form3.MdiParent = Me.MdiParent
Form3.Show()

Form3 has 1 button that when pressed I want it to close Form2.
Form3 has another button when pressed I want it to return the focus to form2.

Don't know why I am having problems with this, doesn't seem like a
compicated thing to do. Any ideas?

Thanks in advance.

--
Kevin

Jul 21 '05 #3
Thanks Alan, that worked great!!
"[Alan Flores]" wrote:
create a holder class

public class AllForms

public Form1 as form1
public Form2 as form2

End class

put this code on each of the form :

private Forms as AllForms

now when you try to create the form add one more line..

Dim 2ndForm As New Form2
2ndForm.MdiParent = Me
Forms.Form2 = 2ndForm
2ndForm.Show()

you can Forms.Form2.Close()
so you can access Forms.Form2.MethodInForm2

do the same in form 1..
"ksedran" wrote:
I forgot to put another question in my original post.

I was wondering if there was a way to access functions on form2 from form3.

For example, when a button is clicked on form3, some action is performed on
form2, like a datagrid refresh for instance.

Thanks again.

"ksedran" wrote:
Hi all,

I am running into an issue trying to close a form from another form.

I have a main form called MainForm.

A child form is opened in the MainForm as follows:
Dim Form2 As New Form2
Form2.MdiParent = Me
Form2.Show()

Now from Form2 I am opening another form as follows:
Dim Form3 As New Form3
Form3.MdiParent = Me.MdiParent
Form3.Show()

Form3 has 1 button that when pressed I want it to close Form2.
Form3 has another button when pressed I want it to return the focus to form2.

Don't know why I am having problems with this, doesn't seem like a
compicated thing to do. Any ideas?

Thanks in advance.

--
Kevin

Jul 21 '05 #4

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

Similar topics

1
by: Eric Cadwell | last post by:
We're running Load Runner to test a large 1.0 based WinForms application. I'm getting the following exception when opening and closing a form 400 - 450 times. The form contains several controls and...
4
by: Elhanan | last post by:
hi.. all a client of ours is considering to move from a dos application to windows desktop application. the application is for traveling agency, the database is rather large. their current...
5
by: Oenone | last post by:
I have a VB.NET form which I'm displaying modally using the ShowDialog() method. Within the form is a Cancel button, and I've set this button into the Form's CancelButton property so that...
3
by: Bob | last post by:
I haver a user login form (winforms app using vs2005 in VB.NET). After succesfull validayion of user I want to open a first form and close the loging form that was used, If I write If...
5
by: Segfahlt | last post by:
I need a little help here please. I have 2 win forms user controls in 2 different projects that I'm hosting in 2 different virtual directories. The controls have been test and operate okay in...
1
by: Pieter | last post by:
Hi, In my application VB.NET 2005 application I placed a ReportViewer, and link it to a server-report: Me.ReportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Remote...
4
by: 3Cooks | last post by:
I have a windows application written in Visual Basic 6.0 that is going to be redeveloped in dotNET. We are trying to decide if we should deploy using Webforms or Winforms and I need advice from...
5
by: brian.wilson4 | last post by:
Our group is currently comparing winforms vs webforms.....app is Corp LAN based - we have control of desktops.....Below is pros and cons list we have come up with - if anything strikes you as...
23
by: raylopez99 | last post by:
Here I am learning WinForms and two months into it I learn there's a WPF API that is coming out. Is this WPF out yet, and is it a threat to WinForms, in the sense that all the library routines I...
2
by: =?Utf-8?B?RXRoYW4gU3RyYXVzcw==?= | last post by:
I am (still) relatively new to Windows applications, most of my experience has been Web based, and I am confused about what exactly happens when the Main() method is called and how to manipulate...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.