I have a DataGridView that is bound to a list of objects called "BaseChange". The BaseChange objects are made up of 4 properties...
- ChangeType
- ChangeStatus
- ChangeDescription
- LastChangeDate
The datagridview has columns for all 4 values as well as a 5th (a checkbox column called "colIsSelected"). There is no problem binding the list to the grid and displaying the items.
The problem is that the query that gets the selected items in the grid is giving me an implicit cast error when option strict is enabled.
This is the query...
Dim _changes As List(Of BaseChange)
_changes = (From _row As DataGridViewRow In dgvChanges.Rows() _
Where Convert.ToBoolean(_row.Cells(NAME_COLUMN_IS_SELECTED).Value) = True _
Select DirectCast(_row.DataBoundItem, BaseChange)).ToList()
...and it produces the correct results with option strict off. The implicit cast squiggle is on the "row As DataGridViewRow" code, and the full message is "Implicit conversion from 'Object' to 'System.Windows.Forms.DataGridViewRow'*".
If I exclude the "As DataGridViewRow" from the query, I get a late binding error on the _row.Cells and _row.DataBoundItem and this also fails option strict.
I need this to work with Option Strict enabled, and in VB. Am I missing something here? Anyone have suggestions?