Home Forums WinForms controls Xceed Grid for WinForms Multiple columns Reply To: Multiple columns

User (Old forums)
Member
Post count: 23064

For each ‘Cell’ in your row, calculate the rectangle (x, y, width, height), and use DrawString. If you want to center the text, change the StringFormat argument.<code>Dim myText As String = … ‘ fill in correct text
Dim myRectangle As Rectangle = new Rectangle(x + 1, y + 1, width – 2, height – 2)
Dim textColor As Color = Me.GetForeColorToPaint
Using textBrush As SolidBrush = New SolidBrush(textColor)
Using textFormat As StringFormat = New StringFormat
textFormat.Alignment = StringAlignment.Center
textFormat.LineAlignment = StringAlignment.Center
e.Graphics.DrawString(myText, Me.Font, textBrush, CType(myRectangle, RectangleF), textFormat)
End Using
End Using</code>

Imported from legacy forums. Posted by Tommy (had 5784 views)