Although I know much more about StarBasic than I do about VB.NET, I am working a project in VB.NET. I decided that I wanted to provide edit controls in a ListView. The easy solution is to set the LabelEdit property to true and then in a double click handler (or similar), you add code like this:
ListViewVarName.SelectedItems(0).BeginEdit()
Dim selCol As Integer = 0
Dim selItem As ListViewItem = Nothing
Private Sub ListViewDBRuns_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListViewDBRuns.MouseDoubleClick
' Returns information about where the mouse was clicked.
' Wow, this is easy, I don't even have to work for it.
Dim hit As ListViewHitTestInfo = ListViewDBRuns.HitTest(e.X, e.Y)
Dim iCol As Integer
Dim iWidth As Integer
For iCol = 0 To hit.Item.SubItems.Count - 1
'OK, now this is a problem. The first item
'has a left point of zero and a right point as wide as ALL of the sub-items.
'First, verify that the mouse was to the right of the left-most point for the column.
If hit.Item.SubItems(iCol).Bounds.Left <= e.X Then
If iCol = 0 And hit.Item.SubItems.Count > 1 Then
'Clicked in column zero and there are more than one columns.
'Check to see if clicked right of the next sub-item (because the right of item-0 is the entire row).
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
'We are to the right of the edge for this sub-item.
'I don't want them to edit column 4.
If iCol = 4 Then
Exit Sub
Else
iWidth = hit.Item.SubItems(iCol).Bounds.Width
Exit For
End If
End If
End If
Next
'Remember the clicked column and item.
selCol = iCol
selItem = hit.Item
'Now, over-lay an edit control on top of the clicked item.
If iCol = 3 Then
DateTimePickerOverlay.Left = ListViewDBRuns.Left + hit.SubItem.Bounds.Left + 3
DateTimePickerOverlay.Top = ListViewDBRuns.Top + hit.SubItem.Bounds.Top
DateTimePickerOverlay.Width = iWidth
DateTimePickerOverlay.Text = hit.SubItem.Text
DateTimePickerOverlay.Visible = True
DateTimePickerOverlay.Focus()
Else
TextBoxOverlay.Left = ListViewDBRuns.Left + hit.SubItem.Bounds.Left + 3
TextBoxOverlay.Top = ListViewDBRuns.Top + hit.SubItem.Bounds.Top
TextBoxOverlay.Width = iWidth
TextBoxOverlay.Text = hit.SubItem.Text
TextBoxOverlay.Visible = True
TextBoxOverlay.Focus()
TextBoxOverlay.SelectAll()
End If
End Sub