How to edit the listview subitems

sardar.nale

New member
Joined
Nov 28, 2011
Messages
1
Programming Experience
Beginner
I want to edit item in the listview which is double clicked
In listview it contains many rows & columns. i am able to edit only first item of row
using following line
listviewWorkGroupDetails.SelectedItems(0).BeginEdit()

How can edit subitems that is how can edit 2nd or 3rd item of row
 
You can't. Just like so many people, you are abusing the ListView. It is NOT (I repeat NOT) a grid control. If you want to edit the fields of a record then you should be using a DataGridView, which is designed for it, rather than a ListView.

If you really want to stick with a ListView then you will need to open a dialogue and edit the record there, then update the item when you're done.
 
As an avid abuser of ListViews I found a way of doing this but it was a giant pain. It requires having a separate class that finds the mouse pos in the control and creates a textbox in the subitem then you have events for that text box. anyway, check out the attachment, create the ListView like this...

VB.NET:
Sub SetupListView()
        myListView = New xListView
        With myListView 
            .Name = "myListView"
            .Size = New System.Drawing.Size(415, 181)
            .Location = New System.Drawing.Point(0, 89)
            .View = View.Details
            .Columns.Add("Item1", 105, HorizontalAlignment.Left)
            .Columns.Add("Item2", 50, HorizontalAlignment.Center)
            .FullRowSelect = True
            .GridLines = True
            .LabelEdit = False        
        End With
        Me.TabControl1.TabPages(0).Controls.Add(myListView)
    End Sub

As stated before this is not the best way of doing this, I just though it looks cool and wanted to see if I could do it.
 

Attachments

  • xListView.zip
    900 bytes · Views: 96
Back
Top