-
Feb 4th, 2018, 04:56 PM
#1
Thread Starter
Fanatic Member
[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.
-
Feb 4th, 2018, 05:14 PM
#2
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?
-
Feb 4th, 2018, 05:41 PM
#3
Thread Starter
Fanatic Member
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
-
Feb 4th, 2018, 06:30 PM
#4
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.
-
Feb 4th, 2018, 06:41 PM
#5
Thread Starter
Fanatic Member
Re: [RESOLVED] Combobox collection
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|