By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,326 Members | 881 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,326 IT Pros & Developers. It's quick & easy.

Specified Cast Is Not Valid

P: n/a
I am attempting to use a bound combo box in a datagrid & am getting the above error.

The code which sets the properties for my combo column is:
Friend WithEvents DataGridComboBoxColumn1 As DataGridTextBoxCombo.DataGridComboBoxColumn

Me.DataGridComboBoxColumn1 = New Proj.DataGridTextBoxCombo.DataGridComboBoxColumn()

Me.DataGridTableStyle1.GridColumnStyles.AddRange(N ew System.Windows.Forms.DataGridColumnStyle() {Me.DataGridTextBoxColumn3, Me.DataGridComboBoxColumn1})

Me.DataGridTableStyle1.MappingName = "DataTableName"

'
'DataGridComboBoxColumn1
'
Me.DataGridComboBoxColumn1.Format = ""
Me.DataGridComboBoxColumn1.FormatInfo = Nothing
Me.DataGridComboBoxColumn1.HeaderText = "Column Header"
Me.DataGridComboBoxColumn1.MappingName = "DataTableColumn"
Me.DataGridComboBoxColumn1.Width = 115
Me.DataGridComboBoxColumn1.ColumnComboBox.DataSour ce = Me.DataSourceName.Tables("LookupTableName")
Me.DataGridComboBoxColumn1.ColumnComboBox.DisplayM ember = "LookupTableName.DescriptionColumn"

Me.DataGridComboBoxColumn1.ColumnComboBox.ValueMem ber = "LookupTableName.OBJECTID"
N.B.
The grid worked before I added this combo-box column.
I remembered to fill the dataset when the form loads.
Any suggestions as to what I can do to find/fix this?
--
Cheers,
James Goodman MCSE, MCDBA
http://www.angelfire.com/sports/f1pictures
Nov 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Have found the solution to this problem:

Me.DataGridComboBoxColumn1.ColumnComboBox.DataSour ce = Me.DataSourceName.Tables("LookupTableName")

Needed to be:
Me.DataGridComboBoxColumn1.ColumnComboBox.DataSour ce = Me.DataSourceName.Tables("LookupTableName").Defaul tView

It then worked perfectly...

--
Cheers,
James Goodman MCSE, MCDBA
http://www.angelfire.com/sports/f1pictures
Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.