• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 340
  • Last Modified:

SHOW FORM USING IMPLEMENTS INTERFACE

Hi All,

I have win app with Mdi Form :

1. ToolStrip with a button for
2. TabControl

I show child form to tabcontrol.

After a child form is added to tabpage, I click mdi form button to show another form that implement at the child form.

The problem is the form at tabpage is gone after the second child form is shown.

What's wrong  ?

Thank you.
0
emi_sastra
Asked:
emi_sastra
  • 6
  • 2
1 Solution
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Impossible to tell without seeing some code....
0
 
emi_sastraAuthor Commented:
Hi Idle_Mind,

At mdi form :

 Private Sub mnuInventoryMasterProduk_Click(sender As Object, e As EventArgs) Handles mnuInventoryMasterProduk.Click

        Dim frmBRWTMPRODUK As New ERV_INVENTORY.frmBRWTMPRODUK

        With frmBRWTMPRODUK

            Dim tbp As New TabPage
            'Dim tbp As New CustomTabPage(frmBRWTMPRODUK)

            tbp.Text = Me.mnuInventory.Text.ToUpper & " - " & .Text
            tbcERPMain.TabPages.Add(tbp)
            .TopLevel = False
            .FormBorderStyle = Windows.Forms.FormBorderStyle.None
            .Dock = DockStyle.Fill

            tbp.Controls.Add(frmBRWTMPRODUK)

            tbcERPMain.SelectedTab = tbp

            .Show()

        End With

    End Sub

Thank you.
0
 
emi_sastraAuthor Commented:
At Child Form :

Public Class frmBRWTMPRODUK

    Implements InterfaceInventory

   Public Sub ShowPendukungInventory() Implements InterfaceInventory.ShowPendukungInventory

        Dim frmMasterPendukungProduk As New frmMasterPendukungProduk

        With frmMasterPendukungProduk

            .ShowDialog(Me.Parent)

        End With

        frmMasterPendukungProduk = Nothing

    End Sub

End Class

When showing form using this function has problem.

Thank you.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
emi_sastraAuthor Commented:
At mdi Form :

Private Sub btnMasterPendukung_Click(sender As Object, e As EventArgs) Handles btnMasterPendukung.Click

        Dim tc As TabControl = CType(Me.tbcERPMain, TabControl)
        Dim TabP As TabPage = DirectCast(tc.TabPages.Item(tc.SelectedIndex), TabPage)

        Dim frm As Form = Nothing

        For Each frm In TabP.Controls
            frm.Close()
        Next

        If Not IsNothing(frm) Then

            Try

                DirectCast(frm, InterfaceInventory).ShowPendukungInventory()

            Catch ex As Exception

            End Try

        End If

    End Sub

Thank you.
0
 
emi_sastraAuthor Commented:
Inside frmBRWTMPRODUK (child form shown in tabpage)

  Private Sub btnMasterPendukung_Click(sender As Object, e As EventArgs) Handles btnMasterPendukung.Click

        Dim frmMasterPendukungProduk As New frmMasterPendukungProduk

        With frmMasterPendukungProduk

            .ShowDialog(Me.Parent)

        End With

        frmMasterPendukungProduk = Nothing
    End Sub

It works fine. The problem exist when using implements.

Thank you.
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
"The problem is the form at tabpage is gone after the second child form is shown."

Well, yeah...you closed it right here:
        For Each frm In TabP.Controls
            frm.Close()
        Next

Open in new window


If you don't want it to disappear, then don't close it?

You could just cast directly without using the loop:
DirectCast(TabP.Controls(0), InterfaceInventory).ShowPendukungInventory()

Open in new window

*This assumes the only thing in the TabPage is that form.
0
 
emi_sastraAuthor Commented:
Silly me.

Let me try first.

Thank you.
0
 
emi_sastraAuthor Commented:
Great. It works.

Thank you very much for your help.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 6
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now