Solved

SHOW FORM USING IMPLEMENTS INTERFACE

Posted on 2013-06-06
8
328 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
  • 6
  • 2
8 Comments
 
LVL 85

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
 
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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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 85

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now