Listview Textbox Edit

Illusionistx

Newcomer
Joined
Aug 31, 2009
Messages
2
I'm using the following code to position a textbox over the selected listview subitem

Code:
dim selSubitem as ListViewItem.ListViewSumItem

    Private Sub ListView1_MouseDoubleClick(......).....
        Dim info As ListViewHitTestInfo = ListView1.HitTest(e.X, e.Y)
        'MessageBox.Show(info.Location.ToString)
        selSubItem = info.SubItem
        txtEdit.Width = info.SubItem.Bounds.Width + 2
        txtEdit.Height = info.SubItem.Bounds.Height
        txtEdit.Location = info.SubItem.Bounds.Location + ListView1.Location
        txtEdit.Text = info.SubItem.Text
        txtEdit.Visible = True
        txtEdit.Focus()
        txtEdit.SelectAll()
    End Sub

But this only works correctly when clicking on an actual subitem
When used on the first column in the listview it makes txtEdit.width = listview.width and not just that column

any ideas on how to fix this or determine whether i clicked the first column or not?
 
Why not check if it is the first subitem and if so adjust the width to the left bound of the second item?
 
perfect solution
thank you.
Code:
        If (selSubItem.Equals(ListView1.Items(info.Item.Index).SubItems(0))) Then
            txtEdit.Width = info.Item.SubItems(1).Bounds.Left
        Else
            txtEdit.Width = info.SubItem.Bounds.Width
        End If
 
Back
Top