[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?
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.
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
Re: [2005] Question in create tabpage with same component
vb.net Code:
Public Class TabPageEx
Inherits TabPage
Public Sub New()
Dim lv As New ListView
With lv
'Set properties here.
End With
Me.Controls.Add(lv)
End Sub
End Class
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
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.