Home All Groups Group Topic Archive Search About

DataGridView DataGridViewComboBoxColumn

Author
20 Jan 2006 4:10 AM
Nathan Franklin
Hey List,

I am trying display a combobox in place of one of my columns in my
DataGridView.
I create the combo box column and assign the
DataGridViewComboBoxColumn.datasource to a datasource to load in value for
my combo box. The fields I use are ID and Description.
I have set the DisplayMember to Description and the ValueMember to ID, but
after the values are loaded in and i set the data source of the dataviewgrid
my combobox column displays the value that has come from the DataSource of
the DataViewGrid.

How can I display to DisplayMember to screen after data has been loaded?

Here is my code below..

' create FieldType column
Dim cmbColFieldType As New DataGridViewComboBoxColumn
cmbColFieldType.DropDownWidth = 160
cmbColFieldType.MaxDropDownItems = 3
cmbColFieldType.FlatStyle = FlatStyle.Flat
cmbColFieldType.DataSource = InteriorSetupTables.Tables("FieldTypes") '
contains values ID and Description
cmbColFieldType.DataPropertyName = "FieldType"
cmbColFieldType.DisplayMember = "Description" ' is a String Value
cmbColFieldType.ValueMember = "ID" ' ID is an INT value
cmbColFieldType.HeaderText = "Field Type"
cmbColFieldType.Name = "FieldType"
cmbColFieldType.ValueType = GetType(System.Int32)
dgExtendedDataSets.Columns.Add(cmbColFieldType)

' SET THE DATASOURCE FOR THIS GRID
dgExtendedDataSets.AutoGenerateColumns = False
dgExtendedDataSets.DataSource = ExTable ' exTable contains columns including
FieldType which is an int value


Thanks very much!
Nathan

Author
20 Jan 2006 4:13 AM
Nathan Franklin
I should add..

The combobox values are listed in the combobox ok, but it just isnt updating
the datagridview's screen

Show quote
"Nathan Franklin" <nat***@tsn.cc> wrote in message
news:dqpnsh$7qi$1@news-02.connect.com.au...
> Hey List,
>
> I am trying display a combobox in place of one of my columns in my
> DataGridView.
> I create the combo box column and assign the
> DataGridViewComboBoxColumn.datasource to a datasource to load in value for
> my combo box. The fields I use are ID and Description.
> I have set the DisplayMember to Description and the ValueMember to ID, but
> after the values are loaded in and i set the data source of the
> dataviewgrid my combobox column displays the value that has come from the
> DataSource of the DataViewGrid.
>
> How can I display to DisplayMember to screen after data has been loaded?
>
> Here is my code below..
>
> ' create FieldType column
> Dim cmbColFieldType As New DataGridViewComboBoxColumn
> cmbColFieldType.DropDownWidth = 160
> cmbColFieldType.MaxDropDownItems = 3
> cmbColFieldType.FlatStyle = FlatStyle.Flat
> cmbColFieldType.DataSource = InteriorSetupTables.Tables("FieldTypes") '
> contains values ID and Description
> cmbColFieldType.DataPropertyName = "FieldType"
> cmbColFieldType.DisplayMember = "Description" ' is a String Value
> cmbColFieldType.ValueMember = "ID" ' ID is an INT value
> cmbColFieldType.HeaderText = "Field Type"
> cmbColFieldType.Name = "FieldType"
> cmbColFieldType.ValueType = GetType(System.Int32)
> dgExtendedDataSets.Columns.Add(cmbColFieldType)
>
> ' SET THE DATASOURCE FOR THIS GRID
> dgExtendedDataSets.AutoGenerateColumns = False
> dgExtendedDataSets.DataSource = ExTable ' exTable contains columns
> including FieldType which is an int value
>
>
> Thanks very much!
> Nathan
>

AddThis Social Bookmark Button