Results 1 to 6 of 6

Thread: [RESOLVED] [2005] Question in create tabpage with same component

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2005
    Posts
    37

    Resolved [RESOLVED] [2005] Question in create tabpage with same component

    How can i create multiple tabpage with same component?
    for example, i had create a listview in tabpage1, how do i copy the listview and put in every tabpage?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Question in create tabpage with same component

    Declare your own class and inherit the TabPage class. In the constructor create a ListView and add it to the page. Now add instances of your class to your TabControl instead of regular TabPages.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2005
    Posts
    37

    Re: [2005] Question in create tabpage with same component

    Quote Originally Posted by jmcilhinney
    Declare your own class and inherit the TabPage class. In the constructor create a ListView and add it to the page. Now add instances of your class to your TabControl instead of regular TabPages.
    can provide any source code so i can refer to? sry that i am new to vb 2k5

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Question in create tabpage with same component

    vb.net Code:
    1. Public Class TabPageEx
    2.     Inherits TabPage
    3.  
    4.     Public Sub New()
    5.         Dim lv As New ListView
    6.  
    7.         With lv
    8.             'Set properties here.
    9.         End With
    10.  
    11.         Me.Controls.Add(lv)
    12.     End Sub
    13.  
    14. End Class
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Member
    Join Date
    Sep 2005
    Posts
    37

    Re: [2005] Question in create tabpage with same component

    thx jmcilhinney, i had use ur way and works well, but why i set the name property ntg has happen? below are the codes:

    Code:
    Public Class TabPageEx
        Inherits TabPage
        Public Sub New()
            Dim lv As New ListView
            Dim clmcode As New ColumnHeader
            Dim symbol As New ColumnHeader
    
            symbol.Text = "Symbol"
            clmcode.Text = "Code"
            With lv
                .Name = "hello"    <--- the name did not display
                .BorderStyle = System.Windows.Forms.BorderStyle.None
                .MultiSelect = True
                .Columns.AddRange(New ColumnHeader() {clmcode, symbol})
                .Dock = System.Windows.Forms.DockStyle.Fill
                .FullRowSelect = True
                .GridLines = True
                .View = System.Windows.Forms.View.Details
            End With
            Me.Controls.Add(lv)
        End Sub
    End Class

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Question in create tabpage with same component

    The Name property of a control is not displayed. It's a way to identify a control within a form's Controls collection. Always read the documentation first. If you use a member and it doesn't work then read its help file to make sure you're using it properly before doing anything else. RTFM applies to software developers more than most, because if we don't read help files then how can we expect the users of our software to do so.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width