Accessing additional combobox columns...


Author
Message
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
What you need to do, Mike, is only set the DisplayMember on the combo box.  When you only set the display member, and leave the ValueMember blank, the combobox's SelectedValue property will return an instance of the business object that was use to populate the combo box.  So, say this is the scenario:

1) you have MyBO dropped on the form
2) you have MyBBS (BusinessBindingSource) dropped on the form
3) you have MyBBS.BusinessObject set to MyBO
4) you have ComboBox1 dropped on the form and the DataSource property set to MyBBS
5) you have ComboBox1.DisplayMember set to "EmployeeName" and the ValueMember property left blank

When you run, the combo box will fill with the EmployeeName for every record in the business object.  When you access the ComboBox1.SelectedValue property, you will receive an instance of the MyBO class (an actual business object), on which, you can access all of the other columns within the business object (no just EmployeeID).

StarkMike
StarkMike
Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)
Group: Forum Members
Posts: 436, Visits: 944
Yes I understand what you are saying. You're talking about basic data binding with the combobox. Let me try to explain my question again.



Lets say in the datatable in my BO I have these fields:

EmployeeID, EmployeeName, EmployeeState



Here is how I set the properties for my combo box.

Value member: EmployeeID

Display member: EmployeeName



I understand that when I click on an item in the combobox that the SelectedValue gets set to whatever value is in EmployeeID.



However, how do I take the value that is in SelectedValue and "query" the BO to find the associated value in EmployeeState?
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
In my previous post, I mentioned the ValueMember property.  Whatever field you associate with the property is what will be used to provide the value when referencing the SelectedValue property.  Does this make sense?
StarkMike
StarkMike
Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)
Group: Forum Members
Posts: 436, Visits: 944
Here is my scenario... I'm not going to use a DevExpress combobox (not an inherited one) and I'm going to bind it to a BBS which is bound to a BO. Now because the datatable in the BO has more columns than the combobox I need to be able to access those columns based on the value member i selected in the combobox. How can I do this?



I hope I have been clear... this binding source stuff has kind of thrown me and some of my code for a loop.
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
This is actually done through the designer.  Just drop a BindingBusinessSource control on the form, choose the business object to wrap on the BusinessBindingSource.  Once this is done, go to your combo box and select the DataSource property and select the BusinessBindingSource.  Then go to the DisplayMember property and ValueMember properties and select the appropriate fields.
StarkMike
StarkMike
Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)
Group: Forum Members
Posts: 436, Visits: 944
Could you provide some code to get me started on that idea?
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
You can, however, use a BusinessBindingSource wrapped around the business object and use it as your DataSource on the combo box (forgoing the PopulationDataSourceSettings) and only set the DisplayMember.  Then, when you access the SelectedValue, it will return an instance of the business object you used to populate the list, and you will have access to all of your properties on the business object.  The downside is that you can only select one field as the DisplayMember (you cannot concatenate more than one of them together), so you will have to concatenate the fields on SQL Server or somewhere else.
StarkMike
StarkMike
Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)
Group: Forum Members
Posts: 436, Visits: 944
Ok. Thanks. I won't ask again. Wink
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
You cannot get more information from a combo box because the DataTable that is created for the combo box only contains the two columns that are the display member and the value member... Ermm
StarkMike
StarkMike
Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)
Group: Forum Members
Posts: 436, Visits: 944
OR if I know how to do this with a DevExpress control that will still work on the inherited controls, right?
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search