6 Answers, 1 is accepted
Thank you for writing.
When RadGridView is about to be printed it sets row heights of the printed document according to the currently used height in the control. In order to accomplish your task you have a couple of options:
- Modify the row heights before printing the grid: GridViewRowInfo
- Use a GridPrintStyle and define a font, this class will also let you modify a number of other settings as well: GridPrintStyle
- Handle the PrintCellFormatting event and access each cell: PrintCellFormatting
Regards,
Hristo Merdjanov
Telerik
Thank you for writing back.
You can modify the row heights individually, including the height of the GridViewSummaryRowElement, which is affected by the value of the TableElement.RowHeight property:
this
.radGridView1.TableElement.RowHeight = 40;
foreach
(GridViewRowInfo row
in
this
.radGridView1.Rows)
{
row.Height = 20;
}
I am also sending you a gif file showing the result on my end.
I hope this helps. Should you have further questions please do not hesitate to write back.
Regards,
Hristo Merdjanov
Telerik
Hi,
I used the above code for change the height for the summary row but, I am not able to change.
Please attach if you have any sample project, or correct way.
My code is here
this.DgvLedger.TableElement.RowHeight = 15;
foreach (GridViewDataRowInfo row in DgvLedger.Rows)
{
row.Height = 15;
}
And I have one more issue in print or preview that is,
The summary row text alignment is different than the data rows.
In a grid data rows and summary rows has right alignment but, when print or preview data row alignment is same as in grid but summary rows alignment from right to middle automatically.
Please refer the attached pic for more
Hi Jamsheer,
I have tested this and the row sizing works on my side (see attached). I would suggest opening a support ticket and attaching your project. This way we will be able to properly investigate this.
To set the alignment you can use the ViewCellFormatting and PrintCellFormatting events. Here is an example:
private void RadGridView1_PrintCellFormatting(object sender, PrintCellFormattingEventArgs e)
{
if (e.Row is GridViewSummaryRowInfo)
{
e.PrintCell.TextAlignment = ContentAlignment.MiddleRight;
}
}
private void RadGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
{
if (e.CellElement is GridSummaryCellElement)
{
e.CellElement.TextAlignment = ContentAlignment.MiddleRight;
}
else
{
e.CellElement.ResetValue(LightVisualElement.TextAlignmentProperty, ValueResetFlags.Local);
}
}
I hope this helps. Should you have any other questions, do not hesitate to ask.
Regards,
Dimitar
Progress Telerik