开发者

.NET Library for drawing tables with GDI+ [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.

Closed 1 year ago.

Improve this question

I need to print the contents of a datagridview, simple text in rows and columns, with GDI+ in .NET to paper.

To do this, I need to iterate over the rows, draw lines, iterate over the columns, calculate width, height, wrap the contents if contents do not fit on one line, etc. This is all开发者_Go百科 possible, but is there a library that simplifies the drawing of tables in GDI+ and abstracts some of the difficulties away?


This is a very common request. Easy keywords, google "print datagridview". Here's a decent looking one.


I've implemented this using XML and XslCompiledTransform.

You need to build your XML (easiest way is using LINQ2XML) and then have your XSLT build the HTML table by enumerating the values your XML produced. You can then represent this in a WebBrowser control, and tell the page to print with WebBrowser.ShowPrintPreviewDialog.

The advantage of using the WebBrowser is having all the page layout tools provided to you so you don't need to worry about it.

Pasting my own implementation would be huge, but please let me know if you need anything clarifying.

Of course, if you have a fixed number of columns, why not try represent it on a report?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜