Illusionistx Posted September 15, 2009 Posted September 15, 2009 I'm using the following code to position a textbox over the selected listview subitem 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? Quote
Leaders snarfblam Posted September 15, 2009 Leaders Posted September 15, 2009 Why not check if it is the first subitem and if so adjust the width to the left bound of the second item? Quote [sIGPIC]e[/sIGPIC]
Illusionistx Posted September 16, 2009 Author Posted September 16, 2009 perfect solution thank you. 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 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.