Click here to Skip to main content
15,886,030 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello. I need to draw a report in c# win forms app. But i am not allowed to use grids or other controls, all i can do is Graphic drawing. So any help or suggestion? The table is so complex and here is printscreen. http://prntscr.com/7hlgbd[^]
Posted
Updated 16-Jun-15 3:04am
v2
Comments
V. 16-Jun-15 9:12am    
what have you tried? Where are you stuck?
Basically you need a panel on which you use the Graphics object to paint lines and text on...
LLLLGGGG 16-Jun-15 9:20am    
You have to use GDI+ and make an image with all your information on it, but, in my opinion, it's annoying from both developer and final user points of view

1 solution

It's not complex: It you are limited to Drawing only, then first set up a Panel (or similar) to draw onto, and handle its Paint event.

Then write a method that takes a DataRow and a Graphics context, and a Y offset. Call it repeatedly for each row in the DataTable.

Inside the method you need to create RectangleF objects for each cell in the row and just call Graphics.DrawText[^], passing it the RectangleF and the cell contents as a string.

Try it: It's really not that complex for a "fixed" table report - it only gets complex if you need to be flexible with the cell count, sizes and location, or text wrapping / ellipsis generation.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900