ListView Column's AddRange is adding the wrong array type of items in InitializeComponent

J

jrhoads23

I have a custom list view "MyListView" (inherited from
System.Windows.Forms.ListView) which has a "Columns" property.
"Columns" if of type "MyColumnHeaderCollection" which is inherited from

System.Windows.Forms.ListView.­ColumnHeaderCollection.
MyColumnHeaderCollection is a collection of "MyColumnHeader" objects
which are inherited from System.Windows.Forms.ColumnHea­der.


I can go in the and add an instance of MyListView to a form and add
columns to it. In the InitializeComponent call, the List View is
created with the correct type (MyListView), the individual columns are
created with the correct type (MyColumnHeader), but the AddRange call
defines the columns as System.Windows.Forms.ColumnHea­der() and not
MyColumnHeader().


What am I doing wrong or missing to get the AddRange call to use the
correct type???


Below is a snip from the automatically generated InitializeComponent
function...


<System.Diagnostics.DebuggerSt­epThrough()> Private Sub
InitializeComponent()
Me.ListView1 = New MyListView
Me.ColumnHeader1 = New MyColumnHeader
Me.ColumnHeader2 = New MyColumnHeader
'
'ListView1
'
Me.ListView1.Columns.AddRange(­New
System.Windows.Forms.ColumnHea­der()
{Me.ColumnHeader1, Me.ColumnHeader2})
Me.ListView1.Location = New System.Drawing.Point(100, 200)
Me.ListView1.Name = "ListView1"
Me.ListView1.TabIndex = 5
End Sub
 
J

joeycalisay

Do you have an AddRange method in your MyColumnHeaderCollection?

--
Joey Calisay
http://spaces.msn.com/members/joeycalisay/


I have a custom list view "MyListView" (inherited from
System.Windows.Forms.ListView) which has a "Columns" property.
"Columns" if of type "MyColumnHeaderCollection" which is inherited from

System.Windows.Forms.ListView.­ColumnHeaderCollection.
MyColumnHeaderCollection is a collection of "MyColumnHeader" objects
which are inherited from System.Windows.Forms.ColumnHea­der.


I can go in the and add an instance of MyListView to a form and add
columns to it. In the InitializeComponent call, the List View is
created with the correct type (MyListView), the individual columns are
created with the correct type (MyColumnHeader), but the AddRange call
defines the columns as System.Windows.Forms.ColumnHea­der() and not
MyColumnHeader().


What am I doing wrong or missing to get the AddRange call to use the
correct type???


Below is a snip from the automatically generated InitializeComponent
function...


<System.Diagnostics.DebuggerSt­epThrough()> Private Sub
InitializeComponent()
Me.ListView1 = New MyListView
Me.ColumnHeader1 = New MyColumnHeader
Me.ColumnHeader2 = New MyColumnHeader
'
'ListView1
'
Me.ListView1.Columns.AddRange(­New
System.Windows.Forms.ColumnHea­der()
{Me.ColumnHeader1, Me.ColumnHeader2})
Me.ListView1.Location = New System.Drawing.Point(100, 200)
Me.ListView1.Name = "ListView1"
Me.ListView1.TabIndex = 5
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top