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. Having a max line count in a list control

Having a max line count in a list control

Scheduled Pinned Locked Moved C#
question
2 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
    BambooMoon
    wrote on last edited by
    #1

    I have some applications that currently use a list control to display status messages from the process. As time goes by, the number of messages in the list would grow without bounds if I did not limit it. I do this by checking if adding a new message will make the line count go over the configured maximum. If so, I delete the first line in the control and then add my new line. There is no real need for the user to interact with the list other than to read it, possibly using the scroll bar. The list control has one column, wide enough for a reasonable length message. The difficulty with this is that it causes a lot of flashing of the control, whether or not I ensure that the newly added line is visible. If messages are rapidly being added to the list, the list can go completely blank for periods of time while tons of updating is going on. So what is a better way? I'm open to anything, particularly to using something other than a list control. Essentially, I'm trying to mimic how a read-only command prompt window works. Once it gets a certain number of lines in it, new lines cause old lines to disappear, with no annoying flicker. Thanks in advance.

    R 1 Reply Last reply
    0
    • B BambooMoon

      I have some applications that currently use a list control to display status messages from the process. As time goes by, the number of messages in the list would grow without bounds if I did not limit it. I do this by checking if adding a new message will make the line count go over the configured maximum. If so, I delete the first line in the control and then add my new line. There is no real need for the user to interact with the list other than to read it, possibly using the scroll bar. The list control has one column, wide enough for a reasonable length message. The difficulty with this is that it causes a lot of flashing of the control, whether or not I ensure that the newly added line is visible. If messages are rapidly being added to the list, the list can go completely blank for periods of time while tons of updating is going on. So what is a better way? I'm open to anything, particularly to using something other than a list control. Essentially, I'm trying to mimic how a read-only command prompt window works. Once it gets a certain number of lines in it, new lines cause old lines to disappear, with no annoying flicker. Thanks in advance.

      R Offline
      R Offline
      Ravi Bhavnani
      wrote on last edited by
      #2

      You may want to envelope your calls to add an item (and remove the first item when the list control is full) between a pair of SuspendLayout() and ResumeLayout() calls. To further increase performance, you may want to consider deleting the first n items (and not just the first item) when the list control is full. /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

      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