Fill List box fast!!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ali poursadri

    #1

    Fill List box fast!!

    Hi,

    I want to fill my list box from a dataset in c#.
    I use adapter and fill command and bind it to a listbox, but it is very slow
    for large data about 500000 records.
    How can I view this list rapid?

    thanks.


  • Chris Hornberger

    #2
    Re: Fill List box fast!!

    Consider adding the ability to "page" thru' your data. 500,000 records
    is beyond being usable to a person.

    Use paging and some well-thought-out search routines rather than
    tossing all the data at the user and praying for results.

    PS... 500,000 rows will take time no matter what you're doing.

    If you *MUST* have those 1/2 millions rows available in a GUI (truly
    doubt it), then fill the list box on a thread and use the async
    methods available to the ado.net libraries.

    Again, I suspect you're just using a poor design model. Humans simply
    WON'T deal with 500000 choices in a listbox.

    "ali poursadri" <apursadri@noor net.net> wrote in message news:<u2APzw1eD HA.3528@tk2msft ngp13.phx.gbl>. ..[color=blue]
    > Hi,
    >
    > I want to fill my list box from a dataset in c#.
    > I use adapter and fill command and bind it to a listbox, but it is very slow
    > for large data about 500000 records.
    > How can I view this list rapid?
    >
    > thanks.[/color]

    Comment

    • Robert Gruen [MSFT]

      #3
      Re: Fill List box fast!!

      Ali,

      In addition to Chris' well thoughtout comments if you really do need to
      display all of those records you can either hide the listbox till it is
      full or use SuspendLayout/ResumeLayout
      (http://msdn.microsoft.com/library/de...-us/cpref/html
      /frlrfsystemwind owsformscontrol classsuspendlay outtopic.asp) to prevent
      spending time painting the control while it is being updated.

      Thanks! Robert Gruen
      Microsoft, VB.NET

      This posting is provided "AS IS", with no warranties, and confers no rights.

      --------------------
      | From: chris@chornbe.c om (Chris Hornberger)
      | Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
      | Subject: Re: Fill List box fast!!
      | Date: 15 Sep 2003 07:05:44 -0700
      | Organization: http://groups.google.com/
      | Lines: 24
      | Message-ID: <53ec8913.03091 50605.131051e3@ posting.google. com>
      | References: <u2APzw1eDHA.35 28@tk2msftngp13 .phx.gbl>
      | NNTP-Posting-Host: 63.118.189.214
      | Content-Type: text/plain; charset=ISO-8859-1
      | Content-Transfer-Encoding: 8bit
      | X-Trace: posting.google. com 1063634744 9708 127.0.0.1 (15 Sep 2003
      14:05:44 GMT)
      | X-Complaints-To: groups-abuse@google.co m
      | NNTP-Posting-Date: 15 Sep 2003 14:05:44 GMT
      | Path:
      cpmsftngxa07.ph x.gbl!cpmsftngx a10.phx.gbl!TK2 MSFTNGXA05.phx. gbl!TK2MSFTNGP0 8
      .phx.gbl!newsfe ed00.sul.t-online.de!t-online.de!news-spur1.maxwell.s yr.edu!n
      ews.maxwell.syr .edu!cyclone.bc .net!sjc70.webu senet.com!news. webusenet.com!p d
      2nf1so.cg.shawc able.net!reside ntial.shaw.ca!s n-xit-03!sn-xit-01!sn-xit-09!su
      pernews.com!pos tnews1.google.c om!not-for-mail
      | Xref: cpmsftngxa07.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1842 16
      | X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
      |
      | Consider adding the ability to "page" thru' your data. 500,000 records
      | is beyond being usable to a person.
      |
      | Use paging and some well-thought-out search routines rather than
      | tossing all the data at the user and praying for results.
      |
      | PS... 500,000 rows will take time no matter what you're doing.
      |
      | If you *MUST* have those 1/2 millions rows available in a GUI (truly
      | doubt it), then fill the list box on a thread and use the async
      | methods available to the ado.net libraries.
      |
      | Again, I suspect you're just using a poor design model. Humans simply
      | WON'T deal with 500000 choices in a listbox.
      |
      | "ali poursadri" <apursadri@noor net.net> wrote in message
      news:<u2APzw1eD HA.3528@tk2msft ngp13.phx.gbl>. ..
      | > Hi,
      | >
      | > I want to fill my list box from a dataset in c#.
      | > I use adapter and fill command and bind it to a listbox, but it is very
      slow
      | > for large data about 500000 records.
      | > How can I view this list rapid?
      | >
      | > thanks.
      |

      Comment

      • martin

        #4
        Re: Fill List box fast!!

        the fastest way to add something to listview is through AddRange method
        (maybe faster would be to use datareader instead of dataset since you need
        to
        create listview items one by one and then pass a collection to method).

        Adding cca 5000 items,each with 12 subitems, with two calculations per item
        and using rather complex sql query takes about 0.6seconds on my Athlon900.
        Without AddRange it takes about 1 minute (adding item one by one





        Comment

        Working...