Solved

SHOW FORM USING IMPLEMENTS INTERFACE

Posted on 2013-06-06
8
332 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
Independent Software Vendors: 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 500 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

730 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