Hi Erel,
I have listViews in my program that use this approach almost verbatim except the names of the controls.
One works perfectly.
When I click the second listView, it tells me the correct position but it returns the wrong value.
For example: I have 5 items in my listview
0) lvd.FirstRow = "FirstItem", lvd.SecondRow = "First Item Details"
1) lvd.FirstRow = "SecondItem", lvd.SecondRow = "Second Item Details"
2) lvd.FirstRow = "ThirdItem", lvd.SecondRow = "Third Item Details"
3) lvd.FirstRow = "ForthItem", lvd.SecondRow = "Forth Item Details"
4) lvd.FirstRow = "FifthItem", lvd.SecondRow = "Fifth Item Details"
Let's say I click on the 2nd row (item 1). It tells me position = 1, Value = [FirstRow = "ForthItem", SecondRow = "Forth Item Details"]
if I check lvd.FirstRow and lvd.SecondRow it confirms the wrong value.
No matter what position I click, it tells me the correct position but the wrong value. The other listView is identical except the names and works correctly.
How can it know the position but not know the actual value of the row when it is clearly displayed where I click?
If you only need the second line then you can add its text as the return value.
If you need both then you create a Type that includes two string values and then add objects of this type:
Code:
Sub Globals
Type ListViewData (FirstRow As String, SecondRow As String)
End Sub
For i = 0 to 100
Dim lvd As ListViewData
lvd.Initialize
lvd.FirstRow = "abc"
lvd.SecondRow= "def"
ListView1.AddTwoLines2(lvd.FirstRow, lvd.SecondRow, lvd)
Next
Sub ListView1_ItemClick(Position As Int, Value As Object)
Dim lvd As ListViewData
lvd = Value
...
End Sub