I have a collection that holds DataGridTextBox Column types, which I
then bind to a DataGrid. I loop through all of the
DataGridTextBox Column that were created and add them to the collection
like this
for(int i=0; i<dataGridStyle ColumnCollectio n.Count; i++)
{
gridTableStyle. GridColumnStyle s.Add((DataGrid TextBoxColumn)d ataGridStyleCol umnCollection[i]);
}
Sometimes, I'll have a DataGridBoolCol umn, which breaks the above code.
I'm trying to put in a conditional that checks the type. This always
gives a warning:
The given expression is never of the provided
('System.Window s.Forms.DataGri dBoolColumn') type
[the expression]
if(dataGridStyl eColumnCollecti on[i].GetType() is DataGridTextBox Column)
gridTableStyle. GridColumnStyle s.Add((DataGrid TextBoxColumn)d ataGridStyleCol umnCollection[i]);
[In the debugger while looping]
- dataGridStyleCo lumnCollection[i].GetType() {System.Runtime Type} System.RuntimeT ype
+ System.Type {"System.Window s.Forms.DataGri dBoolColumn"} System.Type
The debugger shows it is of the provided type. Neither of the above
conditionals ever run. They always evaluate to false. What does the
compiler and debugger say two different things?
Should I use something else to determine the column type?
Thanks,
Brett