We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

PdfGrid Header text position

What is the correct way to center align the text. The following code does not work.

PdfGridRow header = grid.Headers[0];

for (int i = 0; i < grid.Columns.Count; i++)
{
PdfGridCell cell = header.Cells[i];

2 Replies

MT Matt Turnbull February 1, 2010 09:57 AM UTC

sorry message was lost

full code should be

PdfGridRow header = grid.Headers[0];

for (int i = 0; i < grid.Columns.Count; i++)
{
PdfGridCell cell = header.Cells[i];

if (i == 0)
{
}
else
{
cell.Style.StringFormat.Alignment = PdfTextAlignment.Center;
cell.Style.StringFormat.LineAlignment = PdfVerticalAlignment.Middle;
}
}


DG Divya G Syncfusion Team February 1, 2010 10:57 AM UTC

Hi Matt,

Thank you for your interest in syncfusion products.

Kindly refer the below code snippet to align the text.
(C#)

PdfGridRow header = grd.Headers[0];
for (int i = 0; i < grd.Columns.Count; i++)
{
PdfGridCell cell = header.Cells[i];
if (i == 0)
{
}
else
{
PdfStringFormat stringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
cell.StringFormat = stringFormat;
}
}


Please let us know if you have any questions.
Regards,
Divya.G

Loader.
Live Chat Icon For mobile
Up arrow icon