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

How to make a same component visible from two Tab Pages of a Tab control

Hi Experts,

I want to be able to make the same DataGridView component visible no matter which Tab Page is selected on a Tab control. The idea is to use the same DataGridView but using a different column layout.

I could do this with VB6, but with VB.NET it appears that the DataGridView component is a member of one Tab Page only.

The attached graphics show what I have in mind.

1 Solution
Mike TomlinsonMiddle School Assistant TeacherCommented:
"... but with VB.NET it appears that the DataGridView component is a member of one Tab Page only."

That's correct.  A control can only have ONE container.  When you add a control to a container, though, it will automatically be removed from its previous container.

Thus you could do:
    Private Sub TabControl1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles TabControl1.SelectedIndexChanged
        ' Move the DataGridView to the Current Tab:

        ' Change the DataGridView somehow:
        Select Case TabControl1.SelectedIndex
            Case 0
                ' configure the columns for tab 0

            Case 1
                ' configure the columns for tab 1

            Case 2
                ' configure the columns for tab 2

        End Select
    End Sub

Open in new window

LeighWardleAuthor Commented:
Brilliant, thanks, your mind isn't that idle is it?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

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