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

Printing a GridGroupingControl

Thread ID:





27494 Apr 13,2005 03:40 PM UTC Apr 13,2005 11:53 PM UTC WinForms 1
Tags: GridControl
Administrator [Syncfusion]
Asked On April 13, 2005 03:40 PM UTC

Hi, can you tell me what i would have to do to print a GGC with only it''s width fitted onto a page ? I only found samples to either simply print the grid or to fit the whole grid on one page. thank you

Administrator [Syncfusion]
Replied On April 13, 2005 11:53 PM UTC

One way you can do this is to print a bitmap that is scaled to fit in the target rectangle. The sample does this for a GridControl. \Essential Suite\\Windows\Grid.Windows\Samples\In Depth\PrintToFit\ You can use something similar to do it for a GridGroupingControl. Here is some button handler code that shows how you can get a bitmap of a GridGroupingControl through its TableCOntrol. Form f = new Form(); GridModel gridControl1 = this.gridGroupingControl1.TableControl.Model; //draw a fullsize bitmap of the grid... int gridHeight = gridControl1.RowHeights.GetTotal(0, gridControl1.RowCount); int gridWidth = gridControl1.ColWidths.GetTotal(0, gridControl1.ColCount); Bitmap gridBM = new Bitmap(gridWidth, gridHeight); Graphics g = Graphics.FromImage(gridBM); Rectangle saveGridRect = gridControl1.ActiveGridView.GridBounds; gridControl1.ActiveGridView.GridBounds = new Rectangle(0, 0, gridWidth, gridHeight); gridControl1.ActiveGridView.DrawGrid(g); gridControl1.ActiveGridView.ResetGridBounds(); g.Dispose(); //create a bitmap the the proper target size Bitmap picBM = new Bitmap(f.Size.Width, f.Size.Height ); //draw grid bitmap into the new bitmap... System.Drawing.GraphicsUnit gu = System.Drawing.GraphicsUnit.Point; g = Graphics.FromImage(picBM); RectangleF srcRect = gridBM.GetBounds(ref gu); Rectangle destRect = new Rectangle(0, 0, picBM.Width, picBM.Height); g.DrawImage(gridBM, destRect, srcRect, gu); g.Dispose(); //show the new bitmap f.BackgroundImage = picBM; f.Show();


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.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

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