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. Image for the cookie policy date
close icon

Printing a GridGroupingControl

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

1 Reply

AD Administrator Syncfusion Team 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\3.0.1.0\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();

Loader.
Live Chat Icon For mobile
Up arrow icon