You'll need to have the values already concatenated to do this as the
ComboBox can only be bound to a single value and single display column. You
can create an Expression column in your dataset to combine the values of
several other fields.
Peter
--
Peter Foot
Windows Embedded MVP
OpenNETCF.org Senior Advisor
www.inthehand.com |
www.opennetcf.org
"James" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> HERE'S THE SHORT VERSION OF MY QUESTION:
> When using the DisplayMemeber property of a combobox, is it possible
> to concatenate multiple fields from a dataview for use as the value to
> display, or do you have to handle the concatenation in the dataset?
>
> HERE'S THE IN-DEPTH DESC OF WHAT I'M TRYING TO DO:
> I'm writing a Smart Device solution that reads data from an XML
> datasource into a dataset, then I break-out the tables into dataviews
> for to bind to my form's controls.
>
> One of the tables in my dataset is a table that contains information
> about a car, such as Make, Model, Year, etc. The Car table has a
> PrimaryKey called car_id.
>
> I have a combo box that let's the user select a car and see detailed
> information about the car in a datagrid. The combobox is fed from a
> dataview called dvCars and the datagrid is bound to a dataview called
> dvCarDetails. I use the DisplayMember and ValueMember properties of
> the combobox to store the Make of the vehicle and then the vehicle ID
> respectively. When the combo's index changes, the filter for the
> datagrid's dataview is changed to match the selected vehicle using the
> car_id stored in the ValueMember of the combo.
>
> Given that Year, Make nor Model alone is really descriptive enough for
> a user to choose from the selection of cars, is it possible
> concatenate all three (Year, Make & Model) so the concatenated value
> is used as the DisplayMember to help the user choose more accurately?
> I still need to store car_id in ValueMember though, to filter my Car
> Details dataview.
>
> For reference, here's my code:
>
> Private Sub PopulateCmbVehicles()
> Dim VehicleCount, x As Integer
> Dim strVehicleDesc As String
>
> Me.dvCars.RowFilter = "active = 'Y'"
>
> Me.cmbVehicles.DataSource = Me.dvCars
> cmbVehicles.ValueMember = "car_id"
> cmbVehicles.DisplayMember = "make"
> End Sub
>
>
> Private Sub PopulateDG1()
> Dim strFilter As String
> Dim row As DataRowView = CType(cmbVehicles.Items
> _(cmbVehicles.SelectedIndex), DataRowView)
>
> strFilter = "car_id = '" & row("car_id") & "'"
> Me.dvCarDetails.RowFilter = strFilter
> Me.DG1.DataSource = dvCarDetails
>
> End Sub
>
> Thanks much!
> Jamie