We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Alignment of a virtual grid in a printed page

Thread ID:

Created:

Updated:

Platform:

Replies:

59170 Apr 5,2007 06:16 PM UTC Jun 26,2007 02:36 PM UTC WinForms 9
loading
Tags: GridControl
Giles Thomas
Asked On April 5, 2007 06:16 PM UTC

Hi,

We are printing a virtual grid, by adding it to a visible form at location -1000, -1000, wrapping a GridPrintDocument around it, and then calling Print() on the GridPrintDocument. We are setting the margins on the printDocument.PrinterSettings.DefaultPageSettings to zero on all sides, but although the printed grid appears at the top of the page, it is not flush with the left. If there is only one column, then the left-hand side of that column is in the centre of the page. If there are more columns, enough so that if the left-hand side of the first column were in the centre of the page, the right-hand side of the last column would be off the right of the page, then left-hand side is far enough to the right of the centre of the page to make sure that the right-hand side of the last column is on the page.

Or to put it another way - it looks like the code that is positioning the grid on the printed page is (a) trying to centre it, (b) erroneously thinking that the grid is of zero width, and (c) is shifting the grid to the left if the right-hand margin would be off the side of the page.

I hope that's at least reasonably clear...

What I would like to be able to do is to tell the grid to work out its size before it is printed so that (b) does not happen, and to be able to tell the grid to print itself at the top left of the page, so that (a) does not happen.

Or, if my diagnosis is completely wrong and something else is causing the problems I'm seeing - could you perhaps just tell me how to make sure that a virtual grid, when printed, can come out at the top left of the page?


Regards,

Giles

haneefm [Syncfusion]
Replied On April 9, 2007 10:36 AM UTC

Hi Giles,

To customize the printing in a grid, you would handle a couple events on the GridPrintDocument object that you create to do your printing. In its BeginPrint event, you would set the grid margins (in the GridPrintDocument.DefaultPageSettings property) to reserve left and right space, and you may also have to set the GridBounds property. Then in the PrintPage event, you would print your left and right space.

Best regards,
Haneef

Christian Muirhead
Replied On April 12, 2007 02:20 PM UTC

Thanks Haneef -

We're already setting the properties that cover the things you're suggesting:

grid.Properties.PrintColHeader = False
grid.Properties.PrintRowHeader = False
grid.Properties.PrintFrame = False

settings.DefaultPageSettings.Margins.Top = 0
settings.DefaultPageSettings.Margins.Left = 0
settings.DefaultPageSettings.Margins.Bottom = 0
settings.DefaultPageSettings.Margins.Right = 0

Although we aren't setting them in the BeginPrint and PrintPage events. Would this make a difference?

We're using a virtual grid, and are handling the QueryRowCount and QueryColCount events (which should make up the bounds). Do we also need to set the GridBounds property?

Thanks,
Christian

Giles Thomas
Replied On April 13, 2007 10:55 AM UTC

Haneef,

In addition - how do we set the position of the grid on the printed page? Right now, it looks like it's being placed at the top centre.


Regards,

Giles

Giles Thomas
Replied On April 17, 2007 03:22 PM UTC

Hi,

Does anyone at Syncfusion have any thoughts on this? It's becoming a serious issue for us.


Regards,

Giles

Anonymous
Replied On May 8, 2007 10:25 AM UTC

Please respond with a suggestion, or let us know if we haven't provided enough information -- this issue has been blocking us for several weeks now.

haneefm [Syncfusion]
Replied On May 9, 2007 09:43 PM UTC

Hi William,

My sincere appologies in the delay.

This can be acheived by deriving the GridPrintDocument and overriding OnPrintPage Method. Here you can customize it according to your needs.

Please refer to attached sample for implementation.
PrintGridsOnDifferentLocation.zip

Thank you for your patience.

Best regards,
Haneef

Giles Thomas
Replied On June 22, 2007 03:33 PM UTC

Haneef,

Thank you - we had found a workaround shortly after William's post, hence our silence since then. Your suggestion does position the grid correctly on the printed page, but now the row headers are being printed, even though we have set grid.Properties.PrintRowHeader to false. The column headers are not printed.


Regards,

Giles

Giles Thomas
Replied On June 26, 2007 11:32 AM UTC

So is there any way to not only position the grid on the printed page but also suppress the printing of row and column headers?


Regards,

Giles

haneefm [Syncfusion]
Replied On June 26, 2007 02:36 PM UTC

Hi Giles,

If you want to suppress the printing of row header and column header in a grid, then handle the QueryColWidth/QueryRowHeights event(s).

In your event handler, if e.Index point to a rowheader/col header that you don't want to print and if grid.PrintingMode is true, then set e.Size = 0. This will essentially hide any column header/row header you don't want to see. Below is a code snippet

this.grid.Model.QueryRowHeight += new GridRowColSizeEventHandler(Model_QueryRowHeight);
this.grid.Model.QueryColWidth += new GridRowColSizeEventHandler(Model_QueryColWidth);

void Model_QueryColWidth(object sender, GridRowColSizeEventArgs e)
{
if (this.grid.PrintingMode
&& e.Index == 0)
{
e.Size = 0;
e.Handled = true;
}
}

void Model_QueryRowHeight(object sender, GridRowColSizeEventArgs e)
{
if (this.grid.PrintingMode
&& e.Index == 0)
{
e.Size = 0;
e.Handled = true;
}
}

Best regards,
Haneef

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;