How can I change a Cell of a List View

L

Lina Manjarres

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
 
A

Alex Dybenko

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
 
L

Lina Manjarres

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
 
A

Alex Dybenko

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
 
L

Lina Manjarres

I am so sorry Alex, I made a mistake, I was talking about listview, not
treeview.
 
A

Alex Dybenko

Hi Lina,
you can do he same in listview, if also has same property and event
 

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