Administrator

Administrator

  • Tech Writer
  • 2.2k
  • 1.5m

How to Retrieve a ListviewItem

Mar 21 2003 4:49 AM
Hi, I am new to c# (moving across from the VB6 world), and have a question which I haven't been able to figure out the answer to. Basically put, is there any way you can retrieve a ListviewItem by a key value (NOT THE INDEX). In VB this is very easy, for example; Dim loItem As MSComctlLib.ListItem With ListView1 .ListItems.Add , "prussell", "Paul Russell" .ListItems.Add , "dburton", "Dexter Burton" .ListItems.Add , "jthornton", "James Thornton" End With Set loItem = ListView1.ListItems("dburton") If Not loItem Is Nothing Then Debug.Print "Found Dexter Burton" End If I know that I can work around the problem by looping through the ListviewItems in the ListView.Items collection and comparing one of the columns to a key value, but this is a very inefficient way of doing this. Is there anyway that this can be done in c#? Any help would be greatly appreciated NBK

Answers (1)