Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Visual Basic .NET (http://www.programmingforums.org/forum19.html)
-   -   Button to a form (http://www.programmingforums.org/showthread.php?t=3371)

JaDa64 Apr 15th, 2005 7:29 AM

Button control to link two forms
 
i want a button to open a form called form2 but how do i do that. i know how to do so in VB6 but not in 2003 please help

ctor Apr 15th, 2005 11:58 AM

Just call the 'Show' or 'ShowDialog' Method of the Form e.g.
:

Form2 f = new Form2();
f.ShowDialog();

Thats the code in c#, shouldn't be to hard to convert it in vb.

The difference between 'Show' and 'ShowDialog' is that 'ShowDialog' shows the called form modal. So you cant access the mainform as long as the called form isnt closed.

If you want to exchange data between the two forms you have to pass them in the constructor of 'Form2' or write some public properties.

JaDa64 Apr 18th, 2005 7:04 AM

thanks

JaDa64 Apr 18th, 2005 9:10 AM

that makes a new form, i want a form called form 2 to show up, it is alreeady made.

Ooble Apr 18th, 2005 12:06 PM

:

Form2.Show
Not hard, is it?

JaDa64 Apr 19th, 2005 7:55 AM

that doesnt work

ctor Apr 19th, 2005 11:38 AM

Well actually Ooble's 'Form2.Show' cant work as long as you havent a static/shared method in your class 'Form2' called 'Show'.

You have to call 'Show' from a created instance of the class 'Form2'. I think its in VB.NET something like this:
:

Dim formInstance As Form2 = New Form2 // class member
formInstance.Show() // call this in a method


Rory Apr 19th, 2005 11:47 AM

Is showing a form really this hard?

Ooble Apr 19th, 2005 4:19 PM

Apparently so. If the form has already been created, it should be easy. My dog could do it. And I don't even have a dog.

Bharathi Apr 21st, 2005 1:47 AM

Button control to link two forms
 
Hi,


In the Form1, write the code for the okbutton_click() event as shown below.

Private Sub okbutton_Click()
Load Form2
Form2.Caption="This is second form"
Form2.Show
End Sub

LOg on to :http://www.vkinfotek.com


All times are GMT -5. The time now is 10:54 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC