How to get ListView Control subitem by columnHeader Name?

G

Guest

Hi,

i put a listview control in win form and add some columnHeaders, give the
comumnHeader's name, Can i get ListView Control subitem by columnHeader Name ?

Thanks
 
J

Jared

Can't you just create several constants from 0 to 7 as hard coded
references?

const COLUMN1_FIRST NAME as int32 = 1

listview1.selecteditem(0).subitem(COLUMN1_FIRST NAME).text
 
L

Linda Liu [MSFT]

Hi Pony,

Thank you for posting.

You can not use a column header name to get the subitem in a listview. But
you can get the subitem's index by the known column header(eg.
columnHeader1) by the sentence: columnHeader1.Index

So if you want to get the subitem of a known column header(eg.
columnHeader1), you may use the following sentence:
ListViewSubItem item = listView1.Items[0].SubItems[columnHeader1.Index]

Hope this is helpful to you.
If you have any concerns or need anything else, please don't hesitate to
let me know.



Sincerely,
Linda Liu
Microsoft Online Community Support

====================================================
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
====================================================
 

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