How to make a column editable on a listview

Posted on 2011-05-06
Last Modified: 2012-05-11
I have a listview control on a mobile application, and I want to make the last column editable (so the user can enter in a quantity). How would I go about doing this?

private void DisplaySKULots()

            using (ABISS3ServiceB.BasicHttpBinding_Container containerClient = new ABISS3ServiceB.BasicHttpBinding_Container())
                containerClient.Url = NewABISS3ServiceURL(containerClient.Url);
                ABISS3ServiceB.ContainerItem[] containeritem = containerClient.ContainerItems_GetByLPN(textBoxLPN.Text.Trim());


                if (listViewPalletBreakdown.Columns.Count == 0)
                    this.listViewPalletBreakdown.CheckBoxes = false;
                    listViewPalletBreakdown.Columns.Add("SKU", 75, HorizontalAlignment.Left);
                    listViewPalletBreakdown.Columns.Add("Lot", 75, HorizontalAlignment.Left);
                    listViewPalletBreakdown.Columns.Add("Qty", 65, HorizontalAlignment.Left);
                    listViewPalletBreakdown.Columns.Add("UoM", 65, HorizontalAlignment.Left);
                    // TODO: The column below is the only I want to make editable
                    listViewPalletBreakdown.Columns.Add("Qty to New LPN", 65, HorizontalAlignment.Left);

                foreach (ABISS3ServiceB.ContainerItem item in containeritem)
                    listViewPalletBreakdown.Items.Add(new ListViewItem(new string[] { item.VendorSku_Ref, item.LotCode_Ref, item.ConversionItemQty_Ref.ToString(), item.ConversionUnitOfMeasureDesc_Ref, item.VendorProductDescription_Ref }));

Open in new window

Question by:jjliu4492
    1 Comment
    LVL 9

    Accepted Solution

    Unfortunately that is not allowed without jumping through a few hoops. from MSDN:
    Unlike ListViewItem objects, ListViewItem.ListViewSubItem objects cannot be edited directly by the user (the user can edit ListViewItem objects if the LabelEdit property of the ListView control is set to true).

    I'm not sure if any of the following two ideas will work but you can try and see how much effort you will need for it. IMO, DataGridView would be easier to use here.
    1. Rearrange the columns so that the column you want to edit is the main item but is shown last in the UI
    2. Derive a new class from ListViewSubItem and implement the drawing and key strokes handling yourself.

    Featured Post

    Hire Top Freelancers to Complete C# Projects

    Source the talented Expert Exchange community
    for top quality work on your C# projects.

    Hire the best. Collaborate easily. Get quality work.

    Join & Write a Comment

    Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
    Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now