Forms problem

shireenrao

Active member
Joined
Jun 18, 2003
Messages
31
Location
Boston
Hello there

I am building an application, where I start with an MDI. A child is opened through a menu. one of the buttons on this child then opens up Dialog form. I want to execute a function which is part of this dialog forms parent(child to the mdi) from the Dialog form. Can this be done.

Thanks in advance

Srini
 
Pass in the instance of your child to the dialog form when you declare it in the constructor. Edit your dialogs constructor to accept an instance of your child form. Something like this:
Code:
Public Sub New(ByVal formtwo as ChildFormName)
Then manipulate the functions and things like that from that variable.
 
This what I am doing, after changes suggested. Assume main mdi is frmMain, and child(dialog to main) is frmForm1, and the dialog to the child is frmForm2 I am invoking the child by -

Dim frmform1 As New frmForm1()
frmform1.ShowDialog()

Now from the child I want to invoke another form -
Dim frmform2 As New frmForm2(Me)
frmform2.MdiParent = Me.ParentForm
frmform2.Show()

the constructor for frmForm2 is the way you had suggested. I get an error saying "Object reference not set to an instance of the object"

Am I doing something wrong?

Srini
 
Will the Dialog box stay visible after execution of the function?

Because, if not, you could expose public "result (a.k.a desired action) " properties of the dialog form, hide the dialog form (not disposing it), then analyze the result property, the execute the function (locally) and then close the dialog form.
 
Couldnt you make the function in the childform a Public Shared Function and then call it with childform.PublicSharedFunctionName()?
 
I started debugging my code, and found out that I am able to go upto frmform2.Show()
I am getting the error message "Object reference not set to an instance of the object" during formLoad of frmfrom2, when I am trying to add a value to a combobox after a database lookup. The error message comes at
ComboBox1.Items.Add(myReader("ID")).
myReader("ID"), does exist, and I can see what it is.
Why is this happening?

Srini
 
Hey Guys
I figured it out.. As I was using my own constructor, I was not using the default, which was where all the components were getting initialized. I just add
MyBase.New() and
InitializeComponent() to my defined constructor and everything worked out fine.


Srini
 
Back
Top