ListView Index By Name

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"
 
A

Armin Zingler

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
 
A

Armin Zingler

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
 

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