简体   繁体   English

如何在WinForms中打印列或行跨度的DataGridView

[英]How to print column or row spanned datagridview in winforms

I am having trouble wit print data grid view having spanned cells. 我在使用跨越单元格的打印数据网格视图时遇到麻烦。 I followed below article on code project. 我关注了以下有关代码项目的文章。

https://www.codeproject.com/Articles/34037/DataGridVewTextBoxCell-with-Span-Behaviour https://www.codeproject.com/Articles/34037/DataGridVewTextBoxCell-with-Span-Behaviour

I want to print like exactly the same as its displaying the grid view. 我想打印出与显示网格视图完全一样的图像。 Any help would be appreciated. 任何帮助,将不胜感激。

Thanks 谢谢

It depends on how you actually print the DataGridView . 这取决于您实际如何打印DataGridView Here are some examples: 这里有些例子:

HTML (the attribute has same name - ColumnSpan ): HTML(属性具有相同的名称ColumnSpan ):

...
<td colspan=""" + MyCell.ColumnSpan + """>My spanned text</td>
...

Printing it into a table in PDF document using MigraDoc , here the attribute is called MergeRight : 使用MigraDoc将其打印到PDF文档的表格中,此处的属性称为MergeRight

...
TableD5.Rows(0).Cells(0).MergeRight = MyCell.ColumnSpan;
...

The MyCell.ColumnSpan is an object from your link, the article DataGridVewTextBoxCell with Span Behaviour MyCell.ColumnSpan是您链接中的对象,文章DataGridVewTextBoxCell具有跨度行为

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM