Working with multiple Forms

Working with multiple Forms

Post by Rafae » Fri, 16 May 2003 01:03:47



I am starting with Visual Basic.net and I am following a
book of Mastering Visual Basic, it says when I want to
work with multiple Form I have to declare a variable that
references each form and it says I have to put it outside
any procedure.

Below is the code that I wrote, the problem is when I run
the program it doesn't show any form when I declare the
variable form, it only run if I remove that variable
declaration. My question is where I have to declare the
variables in order to run the program.

Code example:

Public Class Form1
    Inherits System.Windows.Forms.Form
    Private forma2 As New WindowsApplication2.Form2()

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

    End Sub

    Protected Overrides Sub Finalize()
        MyBase.Finalize()
    End Sub
End Class

 
 
 

1. Problem working with multiple forms

I have 2 forms in my project.  Form 2 is opened from form 1 and form 2
is used to enter and display data.  It has a few datagrids, and
textboxes.  On form 2 load i create table styles for the datagrids and
databinding for everything.  When the user is finished entering data
they hit the OK button which then hides form 2 using me.hide and
displays form 1 again.  There is a save button on form 1 that when
clicked runs stored procedures.  THe parameters for these stored
procedures comes from Form 2.  My problem arises when the user tries to
open form 2 again after closing it the first time. I get errors saying
I already have table styles and data bindings set. I cannot clear these
databindings or table styles before the user clicks 'Save' because my
stored procedures need these values from form 2.  Does anyone have any
other techniques to use?

Thanks

2. W2K Pro to W2K Pro connection

3. Multiple namespaces in Managed C++ don't work with Form Designer

4. ospf->totally stuby->default route->lsa type 3?

5. working with controls on multiple forms

6. dos plug and play drivers

7. multiple panel vs. multiple forms

8. Novice Needs Printer Driver Help

9. request.form and multiple <form>'s

10. Form Designer doesn't work with Inherited Forms!

11. KeyDown handler not working for multiple custom controls

12. Working around multiple SelectedIndexChanged event firings

13. Activating multiple checkouts doesn't work