for I =1 to 4
ListView1.Items.Add(i)
ListView1.Items(ListView1.Items.Count - 1).SubItems.Add("")
ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(i)
Next
ListView1.Columns.Add("Col1")
ListView1.Columns.Add("Col2")
ListView1.Columns.Add("Col3")
Dim row As String() = New String(3) {}
Dim item As ListViewItem
For i = 1 To 4
row(0) = i
row(2) = i
item = New ListViewItem(row)
ListView1.Items.Add(item)
Next i
Dim iRow, iCol as Integer
Private Sub TextOverlay_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
ListView1.Items(iRow).SubItems(iCol).Text = TextOverlay.Text
End Sub
Private Sub ListView1_Click(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseClick
Dim hit As ListViewHitTestInfo = ListView1.HitTest(e.X, e.Y)
Dim iWidth As Integer
For iCol = 0 To hit.Item.SubItems.Count - 1
If hit.Item.SubItems(iCol).Bounds.Left <= e.X Then
If iCol = 0 And hit.Item.SubItems.Count > 1 Then
If e.X <= hit.Item.SubItems(1).Bounds.Left Then
iWidth = hit.Item.SubItems(1).Bounds.Left
Exit For
End If
ElseIf e.X <= hit.Item.SubItems(iCol).Bounds.Right Then
iWidth = hit.Item.SubItems(iCol).Bounds.Width
Exit For
End If
End If
Next
iRow = hit.Item.Index
TextOverlay.Left = ListView1.Left + hit.SubItem.Bounds.Left + 3
TextOverlay.Top = ListView1.Top + hit.SubItem.Bounds.Top
TextOverlay.Width = iWidth
TextOverlay.Height = 18
TextOverlay.Text = hit.SubItem.Text
TextOverlay.Visible = True
TextOverlay.ReadOnly = False
End Sub