Hm, I did it like this: it seems to work fine.
If e.AlignRight Then
Dim intAlign As Integer
Dim sf As StringFormat
sf = New StringFormat(StringFormat.GenericTypographic)
Dim size As SizeF
size = g.MeasureString(Me.GetColumnValueAtRow(source, rowNum).ToString,
e.TextFont, 500, sf)
intAlign = Me.DataGridTableStyle.GridColumnStyles.Item(Me._col).Width -
size.Width - 5
g.DrawString(Me.GetColumnValueAtRow(source, rowNum).ToString,
e.TextFont, e.ForeBrush, bounds.X + intAlign, bounds.Y + 2)
Else
g.DrawString(Me.GetColumnValueAtRow(source, rowNum).ToString,
e.TextFont, e.ForeBrush, bounds.X, bounds.Y + 2)
End If
Thanks for the suggestion. although I hoped to have a 'nicer' way, hehe :-)
[quoted text, click to view] "Dmitriy Lapshin [C# / .NET MVP]" <x-code@no-spam-please.hotpop.com> wrote
in message news:exMONUk8DHA.1428@TK2MSFTNGP12.phx.gbl...
> Hi,
>
> My guess is to modify the DrawString code in the PaintText override so it
> can take the required alignment into account.
>
> --
> Dmitriy Lapshin [C# / .NET MVP]
> X-Unity Test Studio
>
http://www.x-unity.net/teststudio.aspx > Bring the power of unit testing to VS .NET IDE
>
> "DraguVaso" <pietercoucke@hotmail.com> wrote in message
> news:OKl8w4j8DHA.1636@TK2MSFTNGP12.phx.gbl...
> > Hi,
> >
> > I'm able to set the Font in a Datagrid-Cell to Bold with
> > g.DrawString(Me.GetColumnValueAtRow(source, rowNum).ToString,
e.TextFont,
> > e.ForeBrush, bounds.X, bounds.Y)
> >
> > and to Align the text to Right with
> > MyBase.Paint(g, bounds, source, rowNum, e.BackBrush, e.ForeBrush,
> > e.AlignRight)
> >
> > But I can't figure out how to set it to Bold AND Align Right.
> >
> > Anybody knows how to do this?
> >
> > Thanks a lot in advance,
> >
> > Pieter
> >
> >
>