shireenrao Posted June 25, 2003 Posted June 25, 2003 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 Quote
*Experts* mutant Posted June 25, 2003 *Experts* Posted June 25, 2003 Pass in the instance of your child to the dialog form when you declare it in the constructor. Edit your dialog's constructor to accept an instance of your child form. Something like this: Public Sub New(ByVal formtwo as ChildFormName) Then manipulate the functions and things like that from that variable. Quote
shireenrao Posted June 25, 2003 Author Posted June 25, 2003 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 Quote
Heiko Posted June 25, 2003 Posted June 25, 2003 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. Quote .nerd
rustyd Posted June 25, 2003 Posted June 25, 2003 Couldn't you make the function in the childform a Public Shared Function and then call it with childform.PublicSharedFunctionName()? Quote rustyd
shireenrao Posted June 25, 2003 Author Posted June 25, 2003 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 Quote
shireenrao Posted June 25, 2003 Author Posted June 25, 2003 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 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.