Hi GUys I have a DataGridView bound to a Retrurn DataSet Table From a Database.
One of the columns is an integer which represents a Text Value.
i.e. 40 = HardenSteel
So im my research I thought I would use a DataGridViewComboBoxColumn and attach a table of data with the Integer and corresponding Text Value so that the user can see the text value but it uses the integer value.
Here is the Code that has gets the data and it returns information as expected.
Dim X As clsDataBaseToolsX = New clsDataBaseToolsX()
RetDat(Counter) = X.GetDatabaseDataset("SELECT '[INDEX]', '[NAME]' FROM STEEL").Tables(0)
Then in the loader is:
Dim CBoxCol As DataGridViewComboBoxColumn = New DataGridViewComboBoxColumn
CBoxCol.HeaderText = mColumnHeadings(Index)
CBoxCol.DataPropertyName = mColumnHeadingsDB(Index)
CBoxCol.DisplayStyle = DataGridViewComboBoxDisplayStyle.ComboBox
CBoxCol.DataSource = mColumnExtendEdData(Index)
CBoxCol.ValueMember = mColumnExtendEdData(Index).Columns(0).ToString
CBoxCol.DisplayMember = mColumnExtendEdData(Index).Columns(1).ToString
mDataGrdView.Columns.Add(CBoxCol)
But I always get an error message about
System.FormatException DataGridViewComboBoxCell Value is not Valid.
Can anyone tell what I am doing wrong or at best tell me how to trap for this?
Stephan