One Data Source to Show, One to Pick from in a Combo Box in VB?

  • Thread starter Thread starter PatrickA
  • Start date Start date
P

PatrickA

All,

I have a DataGridView I am creating/filling at runtime from the Data
Source "Widgets."

I am able to add a DataGridViewComboBoxColumn (named ColColor) to that
DataGridView.

When you pull down the drop-down in ColColor, it displays the values
from another Data Source, "Colors."

Is it possible for me to connect ColColor to the Data Source "Widgets"
so that if a color value is already set for a row in that data source,
it shows up in the ColColor when the form loads?

If so, how? Is it in the .DataPropertyName? If so, can anyone help
me with the the syntax?

Here's what I have so far...besides a headache.

With Me.DataGridView1
With ColumnColor
.DataSource = dtCol ' Data source that populates
the selections
.DisplayMember = "Color" 'retrieve values to
display in combo boxes
.ValueMember = "Color" 'column from which to get
values that correspond to what is chosen
.HeaderText = "Color" ' header text
.DataPropertyName = 'gets/sets name of data source
property or db column to which the DGVC is bound.
End With
.Columns.Add(ColumnColor)
End With
 
By the way, I also have a column that is bringing in the color from
the Data Source "Widgets" and displaying it in a "text" field...if
there's an easy way to make that column a DataGridViewComboBoxColumn,
I'm up for that as well.

Thanks
 
Back
Top