Returns a picture of the entire control.
Syntax
val% = [form!]VSFlexGrid.Picture
Remarks
This property returns a picture (bitmap) representation of the entire control, including rows and columns that are not visible on the screen. If you have a control with 1000 rows, for example, the bitmap will include all of them, and the picture will be huge. To create a picture of a part of the control, write a routine to hide all the elements you don't want to show, get the picture, and then restore the control.
To reduce memory requirements for the bitmap and increase speed, you may consider setting the PictureType property to flexPictureMonochrome. The picture will not look as nice, but it will require less memory.
The example below shows a routine that creates a picture of the current selection. It traps out-of-memory errors and automatically switches to monochrome mode if required.
Private Sub CopySelectionAsBitmap(fg As VSFlexGrid)
' save current settings
Dim hl%, tr&, lc&, rd%
hl = fg.HighLight
tr = fg.TopRow
lc = fg.LeftCol
rd = fg.Redraw
fg.HighLight = 0
fg.Redraw = flexRDNone
' hide non-selected rows and columns
Dim i&, r1&, c1&, r2&, c2&
fg.GetSelection r1, c1, r2, c2
For i = fg.FixedRows To fg.Rows - 1
If i < r1 Or i > r2 Then fg.RowHidden(i) = True
Next
For i = fg.FixedCols To fg.Cols - 1
If i < c1 Or i > c2 Then fg.ColHidden(i) = True
Next
' scroll to top left corner
fg.TopRow = fg.FixedRows
fg.LeftCol = fg.FixedCols
' copy picture (with error-trapping)
Clipboard.Clear
On Error Resume Next
fg.PictureType = flexPictureColor
Clipboard.SetData fg.Picture
If Error <> 0 Then
fg.PictureType = flexPictureMonochrome
Clipboard.SetData fg.Picture
Endif
' restore control
fg.RowHidden(-1) = False
fg.ColHidden(-1) = False
fg.TopRow = tr
fg.LeftCol = lc
fg.HighLight = hl
fg.Redraw = rd
End Sub
Data Type
Picture