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. Alternative to listbox/listview

Alternative to listbox/listview

Scheduled Pinned Locked Moved C#
questionlearning
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.
  • Q Offline
    Q Offline
    QzRz
    wrote on last edited by
    #1

    Hello I got a list of words I need to show the user of my application. The list is around 1000 words. I have tried to fill the words in both a listbox and a listview(with view set to detail and 1 columns) I have a button which refres the data in the list, simply by removing them all and then re-fill them, if the list isnt too long it doesnt bother the user, but if the list is 1000 lines (as in my situation) it takes too long time to enter all the data again. I thought there might be some alternative to listbox/listview which is made to handle alot of lines? Otherwise it is probably my code which is wrong, however i'm still in the beginnign phase :) To make an easy test I use this funktion (same for-loop to add data to the listview)

    private void Test()
    {
    this.listBox1.Items.Clear();
    for (int i = 0; i < 1000; i++)
    this.listBox1.Items.Add(i);
    }

    if anyone got something else I can look up in a book or on the internet to find another way to handle this I would be really happy.

    L 1 Reply Last reply
    0
    • Q QzRz

      Hello I got a list of words I need to show the user of my application. The list is around 1000 words. I have tried to fill the words in both a listbox and a listview(with view set to detail and 1 columns) I have a button which refres the data in the list, simply by removing them all and then re-fill them, if the list isnt too long it doesnt bother the user, but if the list is 1000 lines (as in my situation) it takes too long time to enter all the data again. I thought there might be some alternative to listbox/listview which is made to handle alot of lines? Otherwise it is probably my code which is wrong, however i'm still in the beginnign phase :) To make an easy test I use this funktion (same for-loop to add data to the listview)

      private void Test()
      {
      this.listBox1.Items.Clear();
      for (int i = 0; i < 1000; i++)
      this.listBox1.Items.Add(i);
      }

      if anyone got something else I can look up in a book or on the internet to find another way to handle this I would be really happy.

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, whenever you change a Control's property, it will recalculate itself, redo its layout, repaint itself, etc since it does not know in advance whether your change is just one of many, the only one or the last one. When you want to do a lot of changes, you should consider calling Control.SuspendLayout at the beginning, Control.ResumeLayout at the end of the massive change. (or maybe suspend, do a lot, resume, suspend, do another lot, resume, etc). Some Controls also offer an AddRange() method that acts like a "multiple add"; that too can result in speed ups (AFAIK it does not make sense to combine both suspend and addrange). Give it a try on whatever Control suits you most. :)

      Luc Pattyn [Forum Guidelines] [My Articles]


      this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google


      Q 1 Reply Last reply
      0
      • L Luc Pattyn

        Hi, whenever you change a Control's property, it will recalculate itself, redo its layout, repaint itself, etc since it does not know in advance whether your change is just one of many, the only one or the last one. When you want to do a lot of changes, you should consider calling Control.SuspendLayout at the beginning, Control.ResumeLayout at the end of the massive change. (or maybe suspend, do a lot, resume, suspend, do another lot, resume, etc). Some Controls also offer an AddRange() method that acts like a "multiple add"; that too can result in speed ups (AFAIK it does not make sense to combine both suspend and addrange). Give it a try on whatever Control suits you most. :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google


        Q Offline
        Q Offline
        QzRz
        wrote on last edited by
        #3

        Thanks for the good answer I couldt get the Suspend thing to work, but the AddRange() works perfect :)

        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