Rich,
You might want to try something like this:
Create a form with a listview (here called listview1) and a hidden textedit
(here called txtEditWindow). then trap events like so:
Dim li As MSComctlLib.ListItem
Dim nSubitem As Integer
Private Sub Form_Load()
Dim li As MSComctlLib.ListItem
Set li = Me.ListView1.ListItems.Add(, , "Line 1")
li.SubItems(1) = "Hello"
li.SubItems(2) = "fred"
Set li = Nothing
Set li = Me.ListView1.ListItems.Add(, , "Line 2")
li.SubItems(1) = "Hello"
li.SubItems(2) = "fred"
Set li = Nothing
Me.txtEditWindow.Font.Name = ListView1.Font.Name
Me.txtEditWindow.Font.Size = ListView1.Font.Size
Me.txtEditWindow.Font.Charset = ListView1.Font.Charset
Me.txtEditWindow.Font.Weight = ListView1.Font.Weight
Me.txtEditWindow.FontSize = ListView1.Font.Size
Me.txtEditWindow.FontName = ListView1.Font.Name
End Sub
Private Sub ListView1_MouseUp(Button As Integer, Shift As Integer, x As
Single, y As Single)
Dim col As MSComctlLib.ColumnHeader
Set li = Me.ListView1.HitTest(x, y)
If Not li Is Nothing Then
For Each col In ListView1.ColumnHeaders
If col.Left < x And (col.Left + col.Width) > x And
col.SubItemIndex > 0 Then
Me.txtEditWindow.Left = col.Left + ListView1.Left
Me.txtEditWindow.Width = col.Width
Me.txtEditWindow.Height = li.Height
Me.txtEditWindow.Top = li.Top + ListView1.Top
Me.txtEditWindow.Text = li.SubItems(col.SubItemIndex)
Me.txtEditWindow.Visible = True
nSubitem = col.SubItemIndex
End If
Next
End If
End Sub
Private Sub txtEditWindow_LostFocus()
If Not li Is Nothing Then
li.SubItems(nSubitem) = Me.txtEditWindow.Text
Me.txtEditWindow.Visible = False
Set li = Nothing
End If
End Sub
Some tidying up of how the text edit control is shown, hidden, sized etc
probably needs to be done. You also need to have 'FullRowSelect' set on so
the hittest function works when you click on a subitem not just on the main
item.
Hope it's some help.
Steve
-----Original Message-----
From: Rich [mailto:ripatt@h...]
Sent: Wednesday, June 20, 2001 4:58 PM
To: professional vb
Subject: [pro_vb] ListView
Is there a way to just select a subitem on a listview and perform some typr
of function on that subitem
* right click menu, etc. . . . .
Thanks,
Rich
ripatt@h...