Solved

SHOW FORM USING IMPLEMENTS INTERFACE

Posted on 2013-06-06
8
331 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

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 …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

792 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