Click here to Skip to main content
15,897,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
Im using a ListView in my application.I created three columns in that Listview Control.Now i want to extract particular column values by providing the column name.Is it possible to extract the column values by providing column name?
Thanks in advance
Posted
Comments
koool.kabeer 4-Sep-10 13:01pm    
does ListView contain Columns?
Rajesh Sajjanar 5-Sep-10 13:20pm    
For Kool.Kabeer comment : Listview contains columns

1 solution

Hi

No, there is no direct way of extracting column values by using listview column name. You can use the below code to get the value from listview specific column by using the index of the coulmn on subitem, Subitem(0) of listview is for first column of the listview

// Get each row of the Listview for first column
// where i is row number

for (int i = 0; i< this.listView1.ListItems.Count; i++)
{
listView1.ListItems[i].SubItems[i].ToString()
}
 
Share this answer
 
v2
Comments
Sandeep Mewara 5-Sep-10 2:28am    
Her very question asks for value access using a column name. She wants to know if that is possible or not. Such kind of things are needed to avoid index issues in case anything new is added in future.
Rajesh Sajjanar 5-Sep-10 13:51pm    
HI I have very well read question and then posted answer, can you able to post the answer for the same

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900