Spread 8.0 Documentation
Example
Support Options

Glossary Item Box

Example


The following example creates a picture cell that displays a picture and stretches it to fill the cell while maintaining the picture's scale.

To access the file used in this sample, change the path in the code to the path for your product installation's \SAMPLES\FILES directory.

C++

// Define variables
PIC picture;
HBITMAP hBitmap;
// Specify a cell
m_Spread.SetCol(2);
m_Spread.SetRow(3);
// Change height of row to display the picture
m_Spread.SetRowHeight(3,25);
// Set the column width
m_Spread.SetColWidth(2,5);
// Define cell type as picture
m_Spread.SetCellType(CellTypePicture);
// Display a picture
// Convert hBitmap
CPictureHolder picture;
HBITMAP hBitmap = AfxGetApp()->LoadBitmap(IDB_BELL);
picture.CreateFromBitmap(hBitmap);
m_Spread.SetTypePictPicture(picture.GetPictureDispatch());
// Set the picture to stretch to fit the size of the cell
m_Spread.SetTypePictStretch(TRUE);
// Set the picture to proportionally maintain its width
// and height when stretched
m_Spread.SetTypePictMaintainScale(TRUE);

Visual Basic

' Specify a cell
fpSpread1.Col = 2
fpSpread1.Row = 3
' Change height of row to display the picture
fpSpread1.RowHeight(3) = 25
' Set the column width
fpSpread1.ColWidth(2) = 5
' Define cell type as picture
fpSpread1.CellType = CellTypePicture
' Display a picture
fpSpread1.TypePictPicture = LoadPicture("C:\Samples\Files\BELL.BMP")
' Set the picture to stretch to fit the size of the cell
fpSpread1.TypePictStretch = True
' Set the picture to proportionally maintain its width and height when stretched
fpSpread1.TypePictMaintainScale = True

Copyright © GrapeCity, inc. All rights reserved.