Could not get the ColumnHeader.Name?

  • Thread starter Thread starter YXQ
  • Start date Start date
Y

YXQ

I have set the names of each column on design-time, but the code below could
not get their names, why? thank you.

////////////////////////////////////////////////////////////////////////
For Each EachColumnHeader As ColumnHeader In ListView1.Columns
MessageBox.Show(EachColumnHeader.Name)
Next
 
YXQ said:
I have set the names of each column on design-time, but the code below
could
not get their names, why? thank you.

////////////////////////////////////////////////////////////////////////
For Each EachColumnHeader As ColumnHeader In ListView1.Columns
MessageBox.Show(EachColumnHeader.Name)
Next

Did you use databinding which removed the columns?
 
YXQ said:
I have set the names of each column on design-time, but the code below
could
not get their names, why? thank you.

////////////////////////////////////////////////////////////////////////
For Each EachColumnHeader As ColumnHeader In ListView1.Columns
MessageBox.Show(EachColumnHeader.Name)
Next

Strangely it would appear that column header names defined at design time
are not accessible at run-time.
However if you do this
dim header1 as columnheader
header1= new columnheader
header1.text ="My Title"
header1.name="MyColumn1"
listview1.columns.add(header1)

then the name is accessible
 
Thank you, i used the tag property.

Clive Lumb said:
Strangely it would appear that column header names defined at design time
are not accessible at run-time.
However if you do this
dim header1 as columnheader
header1= new columnheader
header1.text ="My Title"
header1.name="MyColumn1"
listview1.columns.add(header1)

then the name is accessible
 
Back
Top