How can I connect a form to a button?  
Author Message
dwalker122010





PostPosted: Visual Basic Express Edition, How can I connect a form to a button? Top

Hi, I was wondering how I can make a button connect to a form so when I click on it it takes me to that form.


Visual Studio Express Editions5  
 
 
Tall Dude





PostPosted: Visual Basic Express Edition, How can I connect a form to a button? Top

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Form2.ShowDialog()

End Sub



 
 
spotty





PostPosted: Visual Basic Express Edition, How can I connect a form to a button? Top

Or more correctly you need to instantiate a new instance of a form class.

As an example I create a new form called form2. This is in fact a class so when I click on the button I would create an instance of the form and then call either the showdialog or the show method to display the new form. In the example case this button would be on an instance of say form1.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim x as new Form2
x.ShowDialog()
End Sub


 
 
Fr4nk1





PostPosted: Visual Basic Express Edition, How can I connect a form to a button? Top

i don't found ShowDialog.

this is VB or C# i want coding for c #

thx bfr


 
 
ReneeC





PostPosted: Visual Basic Express Edition, How can I connect a form to a button? Top

I know VB is hard.

You'll do better in seeking C# in a C# forum rather than a VB forum.