Hi,
I have a problem with alignment with a datagrid.
When I use the SF variable with g.DrawString function, my first Decimal
Column is merged with the previous so my last column is blank.
If I don't use the SF variable everything is ok except that my decimal
values are not aligned on the right.
Do I miss something ?
Stan
Protected Overloads Overrides Sub Paint(ByVal g As Graphics, ByVal bounds As
Rectangle, ByVal source As CurrencyManager, ByVal rowNum As Integer, ByVal
backBrush As Brush, ByVal foreBrush As Brush, ByVal alignToRight As Boolean)
Dim e As DataGridFormatCellEventArgs
e = New DataGridFormatCellEventArgs(rowNum, Me._col,
Me.DataGridTableStyle.DataGrid.Font, backBrush, foreBrush)
RaiseEvent SetCellFormat(Me, e)
If e.UseBaseClassDrawing Then
MyBase.Paint(g, bounds, source, rowNum, backBrush, foreBrush,
alignToRight)
Else
g.FillRectangle(e.BackBrush, bounds)
If Me.GetColumnValueAtRow(source, rowNum).GetType.ToString =
"System.Decimal" Then
Dim SF As New System.Drawing.StringFormat
SF.Alignment = System.Drawing.StringAlignment.Far
g.DrawString(FormatNumber(Me.GetColumnValueAtRow(s ource, rowNum),
2), e.TextFont, e.ForeBrush, bounds.X, bounds.Y, SF)
Else
g.DrawString(Me.GetColumnValueAtRow(source, rowNum).ToString,
e.TextFont, e.ForeBrush, bounds.X, bounds.Y)
End If
End If
If (e.TextFont Is Me.DataGridTableStyle.DataGrid.Font) = False Then
e.TextFont.Dispose()
End If
End Sub