See Also Send us your Feedback
BeeGrid Basics - Using Images
 

The BeeGrid control gives you several ways to show pictures in it. First, you can use a picture object. Second, you can use images from the image list associated with the grid (see the Images property) or the images from the built-in image list. Also, you can load image's binary data directly from a file or a database field.

How to use a picture object?

If you have pictures stored in files use the Visual Basic« LoadPicture method  to load picture object. If you want use a picture stored in the standard Windows resources,  use the Visual Basic« LoadResPicture function to load a picture object. When you save grid's layout with the GetLayoutString method, these pictures will also be saved.

How to use an image list?

To use an external image list, assign list's handle to the Images property. Later, when you want to reference an image from the image list use its index. The BeeGrid control has several built-in pictures and they are represented with constants from sgbipFirst to sgbipLast.

Note: The BkgPicture property cannot use the Image list.

How to load a picture as a byte array?

If a cell's data type is sgtBinary and cell's value is a byte array, BeeGrid will try to interpret byte array values as an image data. Formats supported are the same one supported by the Visual Basic« LoadPicture function. To display image stored as a byte array, follow these instructions:

The code below demonstrates how to display picture from the file by using a byte array:


 Copy Code

Private Sub SGGrid1_OnInit()
   Dim sFile As String
   Dim sWinDir As String
   Dim i As Integer
         
   SGGrid1.RedrawEnabled = False
   'remove all columns
   SGGrid1.Columns.RemoveAll True
   
   'Column creations
   With SGGrid1.Columns.Add("File")
      .Caption = "File name"
      .Width = 2200
   End With
   
   With SGGrid1.Columns.Add("Picture")
      .Caption = ""
      .Width = 305
      .DataType = sgtBinary
      .Style.DisplayType = sgDisplayPicture
   End With
   
   sWinDir = Environ("WINDIR") & "\"
   
   sFile = Dir(sWinDir & "*.bmp", vbNormal)
   
   Dim iFile As Integer, lChunkSize As Long
   Dim arImages() As Byte
   
   Do Until Len(sFile) = 0
      i = i + 1
      SGGrid1.DataRowCount = i
      SGGrid1.Rows.At(i).Cells(0).Value = sFile
      iFile = FreeFile
      lChunkSize = FileLen(sWinDir & sFile)
      
      Open sWinDir & sFile For Binary As iFile

      arImages = (InputB(lChunkSize, iFile))
      SGGrid1.Rows.At(i).Cells(1).Value = arImages
      
      Close iFile
      sFile = Dir
   Loop
   
   SGGrid1.HeadingColCount = 1
   SGGrid1.RedrawEnabled = True
End Sub
	
	

See Also

Images | BkgPicture | DisplayType | PictureAlignment  | BkgPictureAlignment | Samples - Preview Pane | Samples - Countries | Samples - Chess