public class CustomPrintManager : GridPrintManager { SfDataGrid dataGrid; GridRowSizingOptions gridRowSizingOptions = new GridRowSizingOptions(); double Height = double.NaN; public CustomPrintManager(SfDataGrid grid) : base(grid) { dataGrid = grid; }
protected override double GetRowHeight(object record, int rowindex) { if (record != null) { var actualrowindex = GridIndexResolver.ResolveToRowIndex(this.dataGrid, rowindex); if (this.dataGrid.GridColumnSizer.GetAutoRowHeight(actualrowindex, gridRowSizingOptions, out Height)) { return Height; } } return base.GetRowHeight(record, rowindex); }
public partial class MainWindow : Window { GridRowSizingOptions gridRowSizingOptions = new GridRowSizingOptions(); double Height = double.NaN;
public MainWindow() { InitializeComponent(); this.syncgrid.Loaded += syncgrid_Loaded; } void syncgrid_Loaded(object sender, RoutedEventArgs e) { syncgrid.PrintSettings.PrintManagerBase = new CustomPrintManager(this.syncgrid); } private void Button_Click(object sender, RoutedEventArgs e) { syncgrid.PrintSettings.AllowPrintByDrawing = false; syncgrid.ShowPrintPreview(); syncgrid.PrintSettings.AllowColumnWidthFitToPrintPage = true; }
private void Button_Click_1(object sender, RoutedEventArgs e) { syncgrid.Print(); }
|
protected override object GetColumnElement(object record, string mappingName)
{
var element = base.GetColumnElement(record, mappingName);
if (mappingName == "OrderID")
(element as FrameworkElement).VerticalAlignment = VerticalAlignment.Top;
return element;
} |