Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Override Items property in a list view

Override Items property in a list view

Scheduled Pinned Locked Moved C#
tutorialquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bikuni
    wrote on last edited by
    #1

    Does anyone know how to override the Listview items property so that it will populate the listview with my custom ListViewItemCollection? I was able to use: ListViewItemsExtra m_ItemsExtra = new ListViewItemsExtra(); new public ListViewItemsExtra Items { get{ return m_ItemsExtra; } } this did override the property and adds my custom listview items to the collection, but they do not show up in the listview. I was hoping to overide the ListViewItemCollection and have it use my custom Item without redrawing the objects in the listview. Lamont Bullock

    D 1 Reply Last reply
    0
    • B Bikuni

      Does anyone know how to override the Listview items property so that it will populate the listview with my custom ListViewItemCollection? I was able to use: ListViewItemsExtra m_ItemsExtra = new ListViewItemsExtra(); new public ListViewItemsExtra Items { get{ return m_ItemsExtra; } } this did override the property and adds my custom listview items to the collection, but they do not show up in the listview. I was hoping to overide the ListViewItemCollection and have it use my custom Item without redrawing the objects in the listview. Lamont Bullock

      D Offline
      D Offline
      Daniel Monzert
      wrote on last edited by
      #2

      I don't know if you can make the ListView using m_ItemsExtra instead of the, probably, private class member it uses to list its items. Why not trying a different thing? I mean.. if I want more/own functionality in "my" ListViewItem, I'd inherit ListViewItem. public class MyListViewItem : ListViewItem I can still use it with the ListView because it is implicitly casted to ListViewItem (I guess on the implicit cast).

      B 1 Reply Last reply
      0
      • D Daniel Monzert

        I don't know if you can make the ListView using m_ItemsExtra instead of the, probably, private class member it uses to list its items. Why not trying a different thing? I mean.. if I want more/own functionality in "my" ListViewItem, I'd inherit ListViewItem. public class MyListViewItem : ListViewItem I can still use it with the ListView because it is implicitly casted to ListViewItem (I guess on the implicit cast).

        B Offline
        B Offline
        Bikuni
        wrote on last edited by
        #3

        Zarrab, Sorry for not being more clear on how I went about the Listview control. I did create a new Listview class and it does inherit the properties of the .net listview class. This is why I want to override the listview's items collection with my own. I tried creating a new property called ItemsExtra and a custom ListViewItemExtraCollection to store the ListViewItemsExtra class objects. using the get{} accessor I am able to add ListViewItemsExtra to the collection fine, but the IDE doesnt automatically create the code below that it does for a normal listview item. listViewExtra.addrange( new ListViewItemsExtra.ListViewItemsExtraCollection{ this.listViewItemExtra1, this.listViewItemExtra2, this.listViewItemExtra3, etc } ) If I could override the Items property and have it add my custom ItemsExtra object or override the Add() method on the ListViewItemCollection class I may be able to successfully get the ItemExtras in the listview without haveing to redraw them with code. It also works to change the code for a normal listview item to my ItemsExtra object, but that isn't clean like I would like. I want to be able to re-use the control whenever I need it, with the ease of other controls and not have to jerry rig code. Do you have any suggestions? Lamont Bullock

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups