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 update a listbox in another thread in another class

How to update a listbox in another thread in another class

Scheduled Pinned Locked Moved C#
tutorialquestionannouncement
5 Posts 5 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.
  • Y Offline
    Y Offline
    yeah1000
    wrote on last edited by
    #1

    Hi, i need to add some items to a listbox in another thread and another class. The secont thread passes a ListBox item to the invoking function but i cannot access its listbox.items.add functionality. I can only set values to the common parameters to all Controls (i.e. text, name etc.) How could this be solved? ty

    realJSOPR L 2 Replies Last reply
    0
    • Y yeah1000

      Hi, i need to add some items to a listbox in another thread and another class. The secont thread passes a ListBox item to the invoking function but i cannot access its listbox.items.add functionality. I can only set values to the common parameters to all Controls (i.e. text, name etc.) How could this be solved? ty

      realJSOPR Offline
      realJSOPR Offline
      realJSOP
      wrote on last edited by
      #2

      Create a custom event (and custom EventArgs object). Put the string/item into the EventArgs object and handle the event in the desired location.

      .45 ACP - because shooting twice is just silly
      -----
      "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
      -----
      "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001

      1 Reply Last reply
      0
      • Y yeah1000

        Hi, i need to add some items to a listbox in another thread and another class. The secont thread passes a ListBox item to the invoking function but i cannot access its listbox.items.add functionality. I can only set values to the common parameters to all Controls (i.e. text, name etc.) How could this be solved? ty

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

        ... and avoid cross-thread problems with the techniques from this article[^]. :)

        Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


        I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.
        [The QA section does it automatically now, I hope we soon get it on regular forums as well]


        N 1 Reply Last reply
        0
        • L Luc Pattyn

          ... and avoid cross-thread problems with the techniques from this article[^]. :)

          Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


          I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.
          [The QA section does it automatically now, I hope we soon get it on regular forums as well]


          N Offline
          N Offline
          Not Active
          wrote on last edited by
          #4

          It seems multithreading is being taught in class this week. :laugh:


          I know the language. I've read a book. - _Madmatt

          OriginalGriffO 1 Reply Last reply
          0
          • N Not Active

            It seems multithreading is being taught in class this week. :laugh:


            I know the language. I've read a book. - _Madmatt

            OriginalGriffO Offline
            OriginalGriffO Offline
            OriginalGriff
            wrote on last edited by
            #5

            Mark Nischalke wrote:

            It seems multithreading is being badly taught in class this week

            FTFY

            If Barbie is so popular, why do you have to buy her friends? Eagles may soar, but weasels don't get sucked into jet engines. If at first you don't succeed, destroy all evidence that you tried.

            "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
            "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

            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