[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

SHOW FORM USING IMPLEMENTS INTERFACE

Posted on 2013-06-06
8
Medium Priority
?
337 Views
Last Modified: 2013-06-06
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
Comment
Question by:emi_sastra
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 2
8 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 39225963
Impossible to tell without seeing some code....
0
 
LVL 1

Author Comment

by:emi_sastra
ID: 39225995
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
 
LVL 1

Author Comment

by:emi_sastra
ID: 39226006
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!

 
LVL 1

Author Comment

by:emi_sastra
ID: 39226008
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
 
LVL 1

Author Comment

by:emi_sastra
ID: 39226045
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
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 39226046
"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
 
LVL 1

Author Comment

by:emi_sastra
ID: 39226074
Silly me.

Let me try first.

Thank you.
0
 
LVL 1

Author Closing Comment

by:emi_sastra
ID: 39226122
Great. It works.

Thank you very much for your help.
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question