How to Update a Listbox on a Another Form? (C#)


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: How to Update a Listbox on a Another Form? (C#)

  1. #1
    Join Date
    Feb 2006
    Posts
    18

    How to Update a Listbox on a Another Form? (C#)

    Hello. I have a Listbox, listBoxA (say), on FormA. Now, there are two other Forms, FormB and FormC, with textboxes textBoxB and textBoxC.

    The items in listBoxA are added to via textBoxB and textBoxC; either textbox can add an item. Can this be done? How can this be done?

    Here's what I could come up with: Write item from either textbox to a textfile and read the items from the textfile for the listbox. It works but if FormA (with the listbox) is open, I must close it and re-open to see new item(s).

    Anyone know of a better way, especially where I don't have to re-open the Form with the listbox? This is in C#. Thanks!

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    I would create a public method in FormA (AddListItems) that adds item(s) to listBoxA, then call the procedure from forms B & C. In order to do this, forms B & C must have a reference to FormA. If B & C are opened from A, you can pass FormA as a parameter to a public Open or Show method in forms B & C.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Feb 2006
    Posts
    18
    Thanks for the response, Phil. I'll try what you've suggested.

  4. #4
    Join Date
    Aug 2005
    Posts
    46
    how to start a new topic ?

    I cant see any link for that

  5. #5
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Near the top of the page when you're viewing a forum, there's a button labeled, "New Thread." See attached screenshot.
    Attached Images Attached Images
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

Similar Threads

  1. Replies: 3
    Last Post: 03-11-2003, 05:00 PM
  2. Replies: 1
    Last Post: 01-19-2003, 10:32 PM
  3. Update form
    By Barend Esterhuizen in forum VB Classic
    Replies: 1
    Last Post: 12-30-2000, 03:08 AM
  4. Update Database using Data Form Wizard
    By Martin in forum VB Classic
    Replies: 0
    Last Post: 11-10-2000, 11:43 AM
  5. Replies: 1
    Last Post: 04-26-2000, 07:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center