Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Extending the ListViewItem

, 14 May 2009 CPOL
How to extend the ListViewItem to hold an object for a row, and map it to the columns in the ListView control.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ListViewExtendedItem
{
    public class TestClass
    {
        private int _id;
        private string _name;
        private DateTime _date;

        [ListViewColumn("colID")]
        public int ID
        {
            get { return _id; }
            set { _id = value; }
        }
        [ListViewColumn("colName")]
        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }
        [ListViewColumn("colDate")]
        public DateTime Date
        {
            get { return _date; }
            set { _date = value; }
        }

        public TestClass(int id, string name, DateTime date)
        {
            _id = id;
            _name = name;
            _date = date;
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

flavius.stoichescu
Software Developer
Romania Romania
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.141220.1 | Last Updated 14 May 2009
Article Copyright 2009 by flavius.stoichescu
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid