views:

867

answers:

3

Hi,

In onw of our application, we have some reports that need very specific margins that are dependant of the printer the user have. It is used to print into preformated paper with blanks to fill and depending of the printer, the printing is off by some margins. To make things worse, we don't actually control what printer is used because it is not an internal application.

The only solution I could think of is to let the user configure the margins somehow. I though I could just dinamycally change the report margins like I did with datasources and actual report ( I have one control that is used to display every reports from my application and it works alright), but I can't seem to find that damn property to do so. There is a margin property on the report viewer but it's for the form display so it doesn't cut it.

Does anyone knows how to. What I was thinking to do is to define the margins before the user loads the report, i.e. when he clicks on the report button, I load the report, set the margins (or vice-versa is necessary) and then display it.

Before someone mention it, I know the user can, once the report is loaded, change the page setup to fit his needs, but this has two drawbakcs. First one is that it is not saved each time and I need it to be 'saveable' and by users. The second one is that Report viewer seems to have some bugs when the regional setting aren't set to what it's expecting and we can't force the users to changes their setting to accomodate one application.

Thank you.

Eidt : Forgot to mention, it this is of any uses. My reports are all local reports.

A: 

Check out the ReportPageSettings class, part of the report viewer control. Setting those values looks like it should get you what you need.

Jarrett Meyer
Sounds nice but I can't seem to find how to set the values (is it on the local report property, report viewer, or other?)
David Brunelle
They are read-only, it won't work.
cdonner
+1  A: 

You can't do this directly. Try controlling your margins in the report with report parameters.

cdonner
Not sure I understand what you mean? If you mean in the design mode, then I can't really do that. Like mentionned, I need to be able to let any user change it according to his printer. I know it's quite a hassle, but I can't negotiate that. Trust me, I tried to... :o
David Brunelle
In design mode, instead of entering a numeric value, use an expression that references a report parameter. You can let the user type in the parameter, or provide it in some other fashion, when the report is rendered.
cdonner
This would have been really nice but it doesn't work. I tired it already, when I input something else than absolute value (meaning I try to do Parameters!MarginLeft.Value), it gives me an error. I tried with CDbl(Parameters!MarginLeft.Value) and I got the same result
David Brunelle
You are right - margins can't be expressions. I guess that leaves you only with one option - manipulating the RDLC before it is loaded, like you already suggested. Btw, there is an example for this technique on gotreportviewer.com.
cdonner
A: 

Hi, did someone find a solution for this?, i have the same problem, thanks in advance...

JJR
I did find a solution but it's not a cool solution : manipulating the RDLC before it is loaded. Basically I opened it with a filestream and used RegExp to find the right place to modify and modified it.
David Brunelle