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. C#
  4. how to auto refresh listbox values

how to auto refresh listbox values

Scheduled Pinned Locked Moved C#
questionhelptutorialannouncement
4 Posts 3 Posters 1 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
    batmanAgen
    wrote on last edited by
    #1

    hi guys, im listing all the running processes in a machine and put the values inside a listbox control. i want to be able to update the process/application list every, lets say 2 seconds... how can i do that? nid help asap..tnx..:)

    C 1 Reply Last reply
    0
    • B batmanAgen

      hi guys, im listing all the running processes in a machine and put the values inside a listbox control. i want to be able to update the process/application list every, lets say 2 seconds... how can i do that? nid help asap..tnx..:)

      C Offline
      C Offline
      CodyGen
      wrote on last edited by
      #2

      try clearing the listbox before putting your items again. Drop a Timer Control and set the Interval to 2000(2 seconds) and set it to Enable=true: private void timer1_Tick(object sender, EventArgs e) { populatelist(); } private void populatelist() { /*assume that your list of proccesses are coming from an arraylist arlist*/ listBox1.Items.Clear(); for (int i = 0; i < 5; i++) { listBox1.Items.Add(arlist[i].ToString()); } }

      B 1 Reply Last reply
      0
      • C CodyGen

        try clearing the listbox before putting your items again. Drop a Timer Control and set the Interval to 2000(2 seconds) and set it to Enable=true: private void timer1_Tick(object sender, EventArgs e) { populatelist(); } private void populatelist() { /*assume that your list of proccesses are coming from an arraylist arlist*/ listBox1.Items.Clear(); for (int i = 0; i < 5; i++) { listBox1.Items.Add(arlist[i].ToString()); } }

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

        tnx a lot codyGen!:D it worked! although my listbox flickers a bit..:) but it works fine..:D

        RaviBeeR 1 Reply Last reply
        0
        • B batmanAgen

          tnx a lot codyGen!:D it worked! although my listbox flickers a bit..:) but it works fine..:D

          RaviBeeR Offline
          RaviBeeR Offline
          RaviBee
          wrote on last edited by
          #4

          batmanAgen wrote:

          although my listbox flickers a bit

          myListBox.BeginUpdate();
          // refresh contents of myListBox
          myListBox.EndUpdate();

          /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