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
  1. Home
  2. General Programming
  3. C#
  4. Fill Combobox with Large amount of Data

Fill Combobox with Large amount of Data

Scheduled Pinned Locked Moved C#
sales
7 Posts 4 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.
  • N Offline
    N Offline
    Nabawoka
    wrote on last edited by
    #1

    i have more than 55000 Customer and i wanna Fill Combobox with this customers quick .. there is any way to load form quickly and to enter Combobox quickly ** i use background worker but this hang my form and my app is run slowly can i use threading and how i want solutin plz

    private void backWork_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
    {
    if (e.Cancelled)
    {
    }
    else
    {
    FillComboBox();
    cmb3ameelname.Focus();
    Loadform = true;
    cmb3ameelname.SelectedItem = null;
    cmbLandTele.SelectedItem = null;
    }
    }

    private void backWork_DoWork(object sender, DoWorkEventArgs e)
    {
    CusLis = CustomerManger.SelectCustomersAll();
    }

    void FillComboBox()
    {
    cmbameelname.DataSource = CusLis;
    cmbameelname.DisplayMember = "CustName";
    cmbameelname.ValueMember = "CustId";
    }

    frm_load()
    {
    this.backWork.DoWork += new DoWorkEventHandler(this.backWork_DoWork);

        this.backWork.RunWorkerCompleted+=new RunWorkerCompletedEventHandler(this.backWork\_RunWorkerCompleted);
    
      this.backWork.RunWorkerAsync();
    

    }

    L OriginalGriffO S 3 Replies Last reply
    0
    • N Nabawoka

      i have more than 55000 Customer and i wanna Fill Combobox with this customers quick .. there is any way to load form quickly and to enter Combobox quickly ** i use background worker but this hang my form and my app is run slowly can i use threading and how i want solutin plz

      private void backWork_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
      {
      if (e.Cancelled)
      {
      }
      else
      {
      FillComboBox();
      cmb3ameelname.Focus();
      Loadform = true;
      cmb3ameelname.SelectedItem = null;
      cmbLandTele.SelectedItem = null;
      }
      }

      private void backWork_DoWork(object sender, DoWorkEventArgs e)
      {
      CusLis = CustomerManger.SelectCustomersAll();
      }

      void FillComboBox()
      {
      cmbameelname.DataSource = CusLis;
      cmbameelname.DisplayMember = "CustName";
      cmbameelname.ValueMember = "CustId";
      }

      frm_load()
      {
      this.backWork.DoWork += new DoWorkEventHandler(this.backWork_DoWork);

          this.backWork.RunWorkerCompleted+=new RunWorkerCompletedEventHandler(this.backWork\_RunWorkerCompleted);
      
        this.backWork.RunWorkerAsync();
      

      }

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Mohamed Nabawy wrote:

      have more than 55000 Customer and i wanna Fill Combobox with this customers

      :wtf: That's a little bit "too much" to be useful as a dropdown-list. I strongly recommend a popup with a datagridview.

      Mohamed Nabawy wrote:

      . there is any way
      to load form quickly and to enter Combobox quickly

      Databinding is usually a bit slower than slamming the items in there manually.

      Mohamed Nabawy wrote:

      i use background worker but this hang my form and my app is run slowly can i use threading and how
      i want solutin plz

      Threading doesn't make it quicker. You'd load the list async from the DB, but databinding still has to be done on the mainthread. Binding 55000 items to a ComboBox, just to let the user select one, is a bit overkill. Things would really speed up if you convert it to a readonly textbox with a "set"-button. Open a new form (modal), and then load those 55k items. In a virtualized datagridview, if performance is an issue.

      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] They hate us for our freedom![^]

      N 1 Reply Last reply
      0
      • N Nabawoka

        i have more than 55000 Customer and i wanna Fill Combobox with this customers quick .. there is any way to load form quickly and to enter Combobox quickly ** i use background worker but this hang my form and my app is run slowly can i use threading and how i want solutin plz

        private void backWork_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
        if (e.Cancelled)
        {
        }
        else
        {
        FillComboBox();
        cmb3ameelname.Focus();
        Loadform = true;
        cmb3ameelname.SelectedItem = null;
        cmbLandTele.SelectedItem = null;
        }
        }

        private void backWork_DoWork(object sender, DoWorkEventArgs e)
        {
        CusLis = CustomerManger.SelectCustomersAll();
        }

        void FillComboBox()
        {
        cmbameelname.DataSource = CusLis;
        cmbameelname.DisplayMember = "CustName";
        cmbameelname.ValueMember = "CustId";
        }

        frm_load()
        {
        this.backWork.DoWork += new DoWorkEventHandler(this.backWork_DoWork);

            this.backWork.RunWorkerCompleted+=new RunWorkerCompletedEventHandler(this.backWork\_RunWorkerCompleted);
        
          this.backWork.RunWorkerAsync();
        

        }

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

        To add to what Eddy said - it's a very silly idea to put that many items into a control of any sort if you expect the user to have to pick one of them himself. Think about it as a user: how are you going to find the one item you want out of 55,000? How much time are you going to waste looking? Find a better solution! Search, filter, whatever - but not "here's a big list - you sort it out".

        If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.

        "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

        N 1 Reply Last reply
        0
        • N Nabawoka

          i have more than 55000 Customer and i wanna Fill Combobox with this customers quick .. there is any way to load form quickly and to enter Combobox quickly ** i use background worker but this hang my form and my app is run slowly can i use threading and how i want solutin plz

          private void backWork_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
          {
          if (e.Cancelled)
          {
          }
          else
          {
          FillComboBox();
          cmb3ameelname.Focus();
          Loadform = true;
          cmb3ameelname.SelectedItem = null;
          cmbLandTele.SelectedItem = null;
          }
          }

          private void backWork_DoWork(object sender, DoWorkEventArgs e)
          {
          CusLis = CustomerManger.SelectCustomersAll();
          }

          void FillComboBox()
          {
          cmbameelname.DataSource = CusLis;
          cmbameelname.DisplayMember = "CustName";
          cmbameelname.ValueMember = "CustId";
          }

          frm_load()
          {
          this.backWork.DoWork += new DoWorkEventHandler(this.backWork_DoWork);

              this.backWork.RunWorkerCompleted+=new RunWorkerCompletedEventHandler(this.backWork\_RunWorkerCompleted);
          
            this.backWork.RunWorkerAsync();
          

          }

          S Offline
          S Offline
          SledgeHammer01
          wrote on last edited by
          #4

          As others have said 55,000 items in a combobox is a HORRIBLE idea. How is anybody going to find an item in there? Find a better design.

          N 1 Reply Last reply
          0
          • L Lost User

            Mohamed Nabawy wrote:

            have more than 55000 Customer and i wanna Fill Combobox with this customers

            :wtf: That's a little bit "too much" to be useful as a dropdown-list. I strongly recommend a popup with a datagridview.

            Mohamed Nabawy wrote:

            . there is any way
            to load form quickly and to enter Combobox quickly

            Databinding is usually a bit slower than slamming the items in there manually.

            Mohamed Nabawy wrote:

            i use background worker but this hang my form and my app is run slowly can i use threading and how
            i want solutin plz

            Threading doesn't make it quicker. You'd load the list async from the DB, but databinding still has to be done on the mainthread. Binding 55000 items to a ComboBox, just to let the user select one, is a bit overkill. Things would really speed up if you convert it to a readonly textbox with a "set"-button. Open a new form (modal), and then load those 55k items. In a virtualized datagridview, if performance is an issue.

            Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] They hate us for our freedom![^]

            N Offline
            N Offline
            Nabawoka
            wrote on last edited by
            #5

            Eddy Vluggen thanks :)

            1 Reply Last reply
            0
            • S SledgeHammer01

              As others have said 55,000 items in a combobox is a HORRIBLE idea. How is anybody going to find an item in there? Find a better design.

              N Offline
              N Offline
              Nabawoka
              wrote on last edited by
              #6

              HORRIBLE idea :(( :(( :D thanks SledgeHammer01

              1 Reply Last reply
              0
              • OriginalGriffO OriginalGriff

                To add to what Eddy said - it's a very silly idea to put that many items into a control of any sort if you expect the user to have to pick one of them himself. Think about it as a user: how are you going to find the one item you want out of 55,000? How much time are you going to waste looking? Find a better solution! Search, filter, whatever - but not "here's a big list - you sort it out".

                If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.

                N Offline
                N Offline
                Nabawoka
                wrote on last edited by
                #7

                thank OriginalGriff

                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