Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

  • *Experts*
Posted

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.

Posted

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

Posted

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.

.nerd
Posted

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

Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...