Hi,
When I use UltraGridPrintDocument to print a grid the grid is printed inside a border (see attached image). Is there anyway to get rid of this?
It doesn't appear in the PDF when using UltraGridDocumentExporter, which is what I'm trying to achieve when printing.
Kind regards,
Nathan
Hi Nathan,
Application styling overrides the control's settings by default. So there's no property you can set in code that will JUST turn off that one property.
There are a number of options you could use here to get around it. But none of them are really great.
1) You could turn off AppStyling on the grid during the print operation. So that means doing something like this in the InitializePrint:
Private Sub grid_InitializePrint(sender As Object, e As CancelablePrintEventArgs) e.PrintLayout.Grid.UseAppStyling = False e.PrintLayout.BorderStyle = UIElementBorderStyle.NoneEnd Sub
But then you would need to turn it back on in some other event once the print is complete. So you would have to use some event on the UltraGridPrintDocument, like maybe EndPrint. You'd have to modify your code so that the EndPrint could somehow get a reference to the grid, though - your current sample doesn't really allow for this.
2) Another option would be to change the ResolutionOrder in your isl to ControlThenApplication so that the control settings override the isl settings. But this might have unintended consequences and there might be other properties of your grid or other controls that override isl settings that you don't really want to override. It's all or nothing.
I think I found it n the style sheet. If I remove the border from the GridControlArea then it prints out fine. Problem is the grids look silly within the app so they need the border. What can I do to override the style sheet at print time and keep the formatting for the app?
Hi Mike,
The problem appears to be the fact I'm using a style sheet in my project. When I add the same style sheet to your sample project, I get the border.
Could you tell me what I have to turn off in the style sheet? And why don't I get the same behaviour when I export it to a PDF using UltraGridDocumentExporter.
I've added the sample project with the style sheet.
Thanks Mike.
You're right about the second add handler, it should indeed be a remove handler.
However now I'm confused.
Your test sample project worked. Exactly what I want.
I'm not on this project for a day or two, so I'll recheck everything. I won't verify the answer just yet, until I can confirm it working in the my project.
I tried it out using the code you have here and it's working fine for me.
I had to make a couple of small changes to your code. First, you are re-hooking the InitializePrint event in the Finally block. I think you meant to unhook it there. Also, I changed it to show a PrintPreview, instead of printing, so I can test without wasting paper and ink.
I am attaching my sample here. If you run it and click the button, you can see there is no border around the page. If you comment out the code inside the InitializePrint, and try again, you get a border around the page.
Are you talking about some other border?