How to change a populated DataColumn UnderlyingSystemType (app)

  • Thread starter Thread starter John E.
  • Start date Start date
J

John E.

I have a datagrid with one column that is boolean (it is a checkbox column).
So that myDataTable.Column["myColName"]..DataType.UnderlyingSystemType ==
System.Boolean. For printing purposes, I would like to change this from a
boolean to a string, so that I may manipulate the output to read "X" instead
of true, and "" for false. If I attempt to change the DataColumn type
currently, I get an error stating that I cannot change the type of a column
when it has already been populated.

So, how can I convert the column type, with data in it, from boolean to
string, so that I can change all "true" to "X" and all "false" to ""?

Oh, and this is a windows application, not asp.net...if it matters in this
case.

TIA
-John E.
 
John E.

Why would you do this? If you are printing the information, then I
would think that you are performing the operations to print yourself. When
rendering the data in that column, just perform a transformation at that
point.

How is it that you are printing the data?

Another option would be to hide the column, and add a new column that
has an expression where the text is X if it is true, a space if it is false
(the value in the corresponding column for that row). Check the Expression
property of the DataColumn class for more information on this.

Hope this helps.
 
Back
Top