[RESOLVED] Combobox collection-VBForums
Results 1 to 5 of 5

Thread: [RESOLVED] Combobox collection

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    399

    Resolved [RESOLVED] Combobox collection

    I have a combobox that I want to set the properties for in the code instead of the properties window. I could have sworn that I had previously answered this in this forum, but was unable to find the thread. I am using the databindings.add method to show what currently resides in the column.
    The collection for the combobox comes from another table. So I thought what I had below would get the job done. It didn't. I do get the current value, but the list of names from the other table does not show.
    So where did I go wrong....... again.

    Code:
                    .cmbManager.DataSource = frmEvent.tblEmployeeBindingSource
                    .cmbManager.DisplayMember = "strFullName"
                    .cmbManager.ValueMember = "strFullName"
                    .cmbManager.DataBindings.Add(New Binding("Text", frmEvent._MasterBase5_0DataSet, "tblEventMaster.strManager"))
    I know I can, and probably will, set the datasource, displaymember and valuemember in the properties window, but I would still like to understand why this won't work and what I did wrong.

  2. #2
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    3,526

    Re: Combobox collection

    What is the datasource for frmEvent.tblEmployeeBindingSource, my guess is it's a something like _MasterBase5_0DataSet and the Datamember is "tblEmployee". Are you sure that the tblEmploee datatable has been filled?

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    399

    Re: Combobox collection

    Well I am feeling pretty stupid right now. I completely forgot to fill tblEmployee. It works fine now. I have spent most of this morning going through the literature and looking through everything I could think of to understand why, what I thought was a good idea, was not a good idea. What makes this worse is that this was just a little experiment, since I will set all of that from the control properties window anyway. Of course tblEmployee was not loaded and I still might not have noticed that.
    Oh, it does not need the dataset in the DataSource property.

    Thanks Wes

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    97,711

    Re: [RESOLVED] Combobox collection

    A small note: set the DataSource last. The list is populated when you set the DataSource and setting the DisplayMember afterwards meaning changing the list. Setting the DataSource last means no change to the list is required.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    399

    Re: [RESOLVED] Combobox collection

    Gottcha JM. Thanks.

Tags for this Thread

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width