【发布时间】:2020-01-23 11:27:33
【问题描述】:
我正在使用我找到的代码 here 来打印我的数据网格。唯一的问题是我用作 DataGrid 的 ItemsSource 的 DataTable 的列比我在 datagrid 中显示的列多,这些列也被添加到打印输出中。
我怎样才能只添加对流文档可见的值?
for (int j = 0; j < row.Row.ItemArray.Length; j++)
{
r.Cells.Add(new TableCell(new Paragraph(new Run(row.Row.ItemArray[j].ToString()))));
r.Cells.Last().ColumnSpan = 4;
r.Cells.Last().Padding = new Thickness(4);
r.Cells.Last().BorderBrush = Brushes.DarkGray;
r.Cells.Last().BorderThickness = new Thickness(0, 0, 1, 1);
}
【问题讨论】: