How can I change a Cell of a List View

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a list view that I would like to change the data of a cell by
celecting the cell.
This is what I have, but it always return me column 0

Public Function GetRowColumn(ByVal Item As MSComctlLib.ListItem) As String

Dim ColH As ColumnHeader
Dim Index As Long

For Each ColH In ListView2.ColumnHeaders
If Col > (ColH.Left + ListView2.Left) And Col < (ColH.Left +
ListView2.Left + ColH.Width) Then
'Found the column
Index = ColH.Index
Exit For
End If
Next
GetRowColumn = "Row:" & Item.Index & " Column:" & Index
End Function

Private Sub ListView2_ItemClick(ByVal Item As Object)
MsgBox (GetRowColumn(Item))
End Sub

Private Sub ListView2_MouseDown(ByVal Button As Integer, ByVal Shift As
Integer, ByVal x As Long, ByVal y As Long)
Col = x
End Sub

Thanks a lot, Lina
 
Hi Lina,
perhaps you can better explain what do you mean by "change the data of a
cell by selecting the cell"
you can get selected listitem using .Selected property
 
Hi Alex
I have a treeview, and I want the user to be able to change a data, just by
picking the cell and writing something in. Is it posible? Or what would be
the way to do so, because I have a table like this:

2005 1
2006 2
2007 8
2008 10 and so forth

But I want the user to see ti as this:

2005 2006 2007 2008
1 2 8 10

and then the user make a click on the 1 and be able to change it to 8 or
whatever...

I hope i am making myself clear, am I?

Thanks a lot, Lina
 
Hi Lina,
for treeview you can set LabelEdit property to automatic, this will allow
user to edit node text directly in treeview, and then you can use
BeforeLabelEdit event to update table with data entered
 
Back
Top