ListView Index By Name

  • Thread starter Thread starter Derek Hart
  • Start date Start date
D

Derek Hart

Can I get/set a listview column header by name somehow. Seems that it could
be tough to maintain just using the index. This will not work.
lstContacts.Columns("userid").Text = "User ID Here"
 
Derek said:
Can I get/set a listview column header by name somehow. Seems that it
could be tough to maintain just using the index. This will not work.
lstContacts.Columns("userid").Text = "User ID Here"

If you use the designer, there are individual variables holding references
to each column. You can directly access them:

columnheader1.text = "User ID Here"


Otherwise, if you create the columns by (your own) code you can optionally
pass a key to the Add or Insert method of the listview's Columns collection.
Then your code above should work.


Armin
 
Derek said:
Can I get/set a listview column header by name somehow. Seems that it
could be tough to maintain just using the index. This will not work.
lstContacts.Columns("userid").Text = "User ID Here"

If you use the designer, there are individual variables holding references
to each column. You can directly access them:

columnheader1.text = "User ID Here"


Otherwise, if you create the columns by (your own) code you can optionally
pass a key to the Add or Insert method of the listview's Columns collection.
Then your code above should work.


Armin
 
Back
Top