I have a collection that holds DataGridTextBoxColumn types, which I
then bind to a DataGrid. I loop through all of the
DataGridTextBoxColumn that were created and add them to the collection
like this
for(int i=0; i<dataGridStyleColumnCollection.Count; i++)
{
gridTableStyle.GridColumnStyles.Add((DataGridTextB oxColumn)dataGridStyleColumnCollection[i]);
}
Sometimes, I'll have a DataGridBoolColumn, 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.Windows.Forms.DataGridBoolColumn') type
[the expression]
if(dataGridStyleColumnCollection[i].GetType() is DataGridTextBoxColumn)
gridTableStyle.GridColumnStyles.Add((DataGridTextB oxColumn)dataGridStyleColumnCollection[i]);
[In the debugger while looping]
- dataGridStyleColumnCollection[i].GetType() {System.RuntimeType} System.RuntimeType
+ System.Type {"System.Windows.Forms.DataGridBoolColumn"} 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