I have a DataGridLabelColumn I've made by overriding a DataGridColumnStyle
object. (based on an MSDN article by Chris Sano).
In the Paint method, I use a StringFormat object, and pass that to a
Graphics.DrawString method. I am finding that the strings I am passing to
the drawstring method are being manipulated: text suffixed with a "?" or
")" are being painted with the "?" as a PRE-fix, and my ")" is being moved
to the front of the string and being painted (for lack of a better word) as
"(". If I remove my StringFormat from the DrawString call, then this
behaviour goes away and the string is painted as is. I looked on MSDN for
some clarification but it doesn't detail how strings are interpreted, nor
how to prevent this behaviour.
Any guidance would be appreciated.
The following is the code snippet.
StringFormat sf = new StringFormat();
sf.Alignment = StringAlignment.Far;
sf.LineAlignment = StringAlignment.Center;
sf.FormatFlags = StringFormatFlags.DirectionRightToLeft |
StringFormatFlags.FitBlackBox;
g.FillRectangle( backBrush, bounds );
g.DrawString(
this.GetColumnValueAtRow( source, rowNum ).ToString(),
this.DataGridTableStyle.DataGrid.Font,
foreBrush,
bounds, sf ); //<-- if sf is ommitted here, then the my weird string
formatting goes away