I want to open an Instance of a form in MDI Container

here is my code
I just want an instance of a form to Edit records in the database

Private Sub BtnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnEdit.Click
        Dim Emp As New Employee()

        Emp.MdiParent = Me
        Emp.Show()


    End Sub

I'm getting this error when I click on Edit button

Form that was specified to be the MdiParent for this form is not an MdiContainer. Parameter name: value

I want the new form to open inside the MDI container

Re: opening form in mdi container 80 80

In the properties of the MdiParent look for IsMdiContainer and set that to true.

Re: opening form in mdi container 80 80

as you can see in the screen shot my ISMdiContainer is set true

MDI

Re: opening form in mdi container 80 80

Did you start the form as an MDI Parent Form? I'm not sure of everything that's required to make a form an MDI Parent but I suspect that there is an obscure property that is required. Using the standard template and modifying it might bring better results.

Re: opening form in mdi container 80 80

The screenshot I provided with the properties is the parent MDI form ,and inside Employee form I have a button EDIT(for editing recored)I have put the above code in that and I want the new window to open inside the parent MDI form

How can I do that?

Re: opening form in mdi container 80 80

assign mainform as the parent for the new form and use the show method

NewForm.MDIParent = MainForm
NewForm.Show()
Re: opening form in mdi container 80 80

Thank you "tinstaafl" one hurdal clear ,many more to go.:)

Re: opening form in mdi container 80 80

As I said now again a new hurdal >>>

Private Sub BtnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnEdit.Click
        Dim Emp As New Employee()
        Emp.MdiParent = Mainfrm
        Emp.Show()
        DGVload1()
        BtnEdit.Text = "new edit"
    End Sub

Now I want to make a new button on the instance form ,because whenever I click on the edit button (Old button)new form is opened.I want a button where I can edit content in the tables .

Re: opening form in mdi container 80 80

Are you talking about a button in the toolbar or on the form?

Re: opening form in mdi container 80 80

on the new form

Re: opening form in mdi container 80 80

You can easily add it in the design window, then double-click it and the code stub will show. Add your code in there. If you want it in a toolbar, just add one to the mdi child the same as you added for the mdi parent

Re: opening form in mdi container 80 80

Form that was specified to be the MdiParent for this form is not an MdiContainer.
Parameter name: value

i got this error how can i solve it please help me

Re: opening form in mdi container 80 80

Set the IsMdiContainer property to True on your parent form.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.