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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Updating ListView items in realtime. how?

Updating ListView items in realtime. how?

Scheduled Pinned Locked Moved .NET (Core and Framework)
csharpquestioncssdotnetgraphics
3 Posts 2 Posters 2 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.
  • R Offline
    R Offline
    Ruth Ivimey Cook
    wrote on last edited by
    #1

    Hi folks, Background: I am creating a control using VS2005 .NET Framework that reports on the progress of some background processes. There is no concept of data entry or selection here; the only user action is to scroll the list if required. The current implementation of this uses a ListBox-derived control with drawing code implemented in the DrawItem event handler. That code works (more or less) fine when the data that backs each item in the list is static. I have two items that change dynamically: a progress bar and a text field that must be able to change fairly quickly over time. The current implementation includes custom drawing code for the whole - there are no child controls. My problem is that although I can change the value of the data field easily enough, all I can think of doing to make the ListBox aware of the change is to call Invalidate() for the whole control, and the paint events don't keep up, and the resulting effect is very jerky - tending in fact towards only updating once the progress reaches 100% The reason for a global Invalidate is that I am not aware of anything in ListBox that enables me to discover where an individual item is on screen, so I can't paint it explicitly or do a bounded invalidate. I am wondering if ListView offers that ability, but can't see it if that's so. So, to put the question straight: With an owner drawn list box/view, how to I tell the control that a (sub)item must be repainted now - preferably this instant - because the data backing it has changed? Regards Ruth Ruth Ivimey-Cook VS2005 / C# & VB

    R 1 Reply Last reply
    0
    • R Ruth Ivimey Cook

      Hi folks, Background: I am creating a control using VS2005 .NET Framework that reports on the progress of some background processes. There is no concept of data entry or selection here; the only user action is to scroll the list if required. The current implementation of this uses a ListBox-derived control with drawing code implemented in the DrawItem event handler. That code works (more or less) fine when the data that backs each item in the list is static. I have two items that change dynamically: a progress bar and a text field that must be able to change fairly quickly over time. The current implementation includes custom drawing code for the whole - there are no child controls. My problem is that although I can change the value of the data field easily enough, all I can think of doing to make the ListBox aware of the change is to call Invalidate() for the whole control, and the paint events don't keep up, and the resulting effect is very jerky - tending in fact towards only updating once the progress reaches 100% The reason for a global Invalidate is that I am not aware of anything in ListBox that enables me to discover where an individual item is on screen, so I can't paint it explicitly or do a bounded invalidate. I am wondering if ListView offers that ability, but can't see it if that's so. So, to put the question straight: With an owner drawn list box/view, how to I tell the control that a (sub)item must be repainted now - preferably this instant - because the data backing it has changed? Regards Ruth Ruth Ivimey-Cook VS2005 / C# & VB

      R Offline
      R Offline
      Robert Rohde
      wrote on last edited by
      #2

      The ListBox has a public GetItemRectangle[^] function which will tell you the bounds. You could put this one into the Invalidate call.

      R 1 Reply Last reply
      0
      • R Robert Rohde

        The ListBox has a public GetItemRectangle[^] function which will tell you the bounds. You could put this one into the Invalidate call.

        R Offline
        R Offline
        Ruth Ivimey Cook
        wrote on last edited by
        #3

        I eventually solved the problem using the List View SubItem Bounds property, which returns the bounds of the specific SubItem. I check that the bounds are contained by the parent's ClientRectangle, to avoid invalidate calls for items that are invisible, then pass the Bounds into the Invalidate call as Robert suggested. This is still slightly flickery, but not too bad. Thanks. Ruth Ivimey-Cook VS2005 / C# & VB

        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