Closed Thread
Results 1 to 4 of 4

Thread: Howto: Populate info into combobox

  1. #1
    dirkfirst is offline Programming Expert
    Join Date
    May 2006
    Posts
    354
    Rep Power
    23

    Howto: Populate info into combobox

    Just learned how to do this. Here it is:

    1) Add your combobox to your form
    2) On button press or form load or whatever use
    I used the Form1_Load

    Code:
            private void Form1_Load(object sender, EventArgs e)
            {
                comboBox1.Items.Add("Object 1");
                comboBox1.Items.Add("Object 2");
            }
    You can use the same thing to remove items

    Code:
            private void Form1_Load(object sender, EventArgs e)
            {
                comboBox1.Items.Add("Object 1");
                comboBox1.Items.Add("Object 2");
    
                comboBox1.Items.Remove("Object 1");
            }

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    brackett is offline Programmer
    Join Date
    May 2006
    Posts
    192
    Rep Power
    22
    IIRC, there's a BeginUpdate and EndUpdate method pair on the combobox as well. If you're going to insert a lot of items, it's worth it to call those for perf reasons - it'll basically disable message pump processing while adding items.

  4. #3
    NeedHelp Guest
    Quote Originally Posted by brackett
    IIRC, there's a BeginUpdate and EndUpdate method pair on the combobox as well. If you're going to insert a lot of items, it's worth it to call those for perf reasons - it'll basically disable message pump processing while adding items.

    What is Message Pump? I've never heard of BeginUpdate or EndUpdate - does this keep it from showing each insert as it is inserted?

  5. #4
    brackett is offline Programmer
    Join Date
    May 2006
    Posts
    192
    Rep Power
    22
    Quote Originally Posted by NeedHelp
    What is Message Pump? I've never heard of BeginUpdate or EndUpdate - does this keep it from showing each insert as it is inserted?
    The message pump is basically the thread that runs in your app and responds to user events (key presses and mouse clicks) and tells controls to repaint themselves.

    Yes - it keeps the control from responding to the repaint calls until EndUpdate is called - meaning it doesn't redraw itself as new items are being inserted. You could also use AddRange, which would allow you to add an array of objects at once.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Populate Combobox from Access Database
    By Aelustelin in forum C# Programming
    Replies: 1
    Last Post: 09-06-2011, 02:17 AM
  2. Replies: 1
    Last Post: 03-30-2010, 11:16 AM
  3. Howto :Invoice
    By Nikolasr in forum Visual Basic Programming
    Replies: 1
    Last Post: 02-01-2010, 11:21 PM
  4. HOWTO install PerCobol on Ubuntu 8.04
    By Coldhearth in forum Software Development Tools
    Replies: 4
    Last Post: 10-07-2008, 08:16 AM
  5. Howto use global variables
    By dirkfirst in forum PHP Development
    Replies: 4
    Last Post: 07-15-2006, 12:19 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts