|
Bitmap bitMap = new Bitmap(this.gridControl1.ClientRectangle.Width, this.gridControl1.ClientRectangle.Height);
this.gridControl1.DrawToBitmap(bmp, new Rectangle(0, 0, bmp.Width, bmp.Height));
//To save the image locally.
bmp.Save("GridControl.png"); |
|
Query |
Solution |
|
Error CS1061 'PdfLoadedDocument' does not contain a definition for 'ImageExportSettings' and no extension method 'ImageExportSettings' accepting a first argument of type 'PdfLoadedDocument' could be found (are you missing a using directive or an assembly reference?) |
We have prepared a sample based on our latest version 16.2.0.41. Seems that you are using the older version. There is no need to use this property for exporting the grid to pdf. Moreover, we have modified sample here. |
|
is it possible to have the example in VB Net language? |
We have prepared the sample in vb.Net as per your request. We have done the following changes in attached sample in order to achieve the grid to image saving with the control cell type as it is.
We have implemented the CustomCellRenderer for Control CellType to adjust the image size while converting to pdf using PrintingMode property in OnDraw method to avoid the image overlapping issue. So, please make use of the below custom cell renderer to overcome the mentioned issue. Please refer to the below code example,
Code example
Me.gridControl1.CellRenderers("Control") = NewCustomGenericCellRenderer(Me.gridControl1,Me.gridControl1.CellModels("Control"))
Public Class CustomGenericCellRenderer
Inherits GridGenericControlCellRenderer
Public Sub New(ByVal grid As GridControlBase,ByVal model As GridCellModelBase)
MyBase.New(grid, model)
End Sub
Private bounds As Rectangle = Rectangle.Empty
Private rControl As Control = Nothing
Protected Overrides Sub OnDraw(ByVal g AsGraphics, ByVal clientRectangle As Rectangle, ByValrowIndex As Integer, ByVal colIndex As Integer, ByValstyle As GridStyleInfo)
If Me.Grid.PrintingMode Then
Me.Grid.PrintingMode = False
MyBase.OnDraw(g, clientRectangle, rowIndex, colIndex, style)
Me.Grid.PrintingMode = True
End If
Else
MyBase.OnDraw(g, clientRectangle, rowIndex, colIndex, style)
End If
End Sub
End Class |
|
Dim gridHeight As Integer = Me.gridControl1.Model.RowHeights.GetTotal(0, Me.gridControl1.Model.RowCount)
Dim gridWidth As Integer = Me.gridControl1.Model.ColWidths.GetTotal(0, Me.gridControl1.Model.ColCount)
Dim bmp As Bitmap = New Bitmap(gridWidth, gridHeight)
Dim graphics As Graphics = Graphics.FromImage(bmp)
Me.gridControl1.SuspendLayout()
Me.gridControl1.GridBounds = New Rectangle(0, 0, gridWidth, gridHeight)
'To draw the Grid in bitmap graphics.
Me.gridControl1.DrawGrid(graphics)
bmp.Save("GridControl.png")
Me.gridControl1.ResetGridBounds()
Me.gridControl1.ResumeLayout()
graphics.Dispose() |