[]
        
(Showing Draft Content)

Setting a Background Image to a Cell

You can customize the background of a cell by adding a graphic image.

Spread WinForms applies a BackgroundImage to an individual merged cell range containing a visible animal photograph.

For more information on image cell types, refer to Setting an Image Cell.

For more information on setting an image for all the cells in a sheet (as part of the default style) refer to Setting a Background Image for a Sheet.

Example

The following example adds an image to a text cell.

private void Form1_Load(object sender, System.EventArgs e)
{
// Create an instance of a text cell.
FarPoint.Win.Spread.CellType.TextCellType t = new FarPoint.Win.Spread.CellType.TextCellType();
// Load an image file and set it to BackgroundImage property.
FarPoint.Win.Picture p = new FarPoint.Win.Picture(Image.FromFile("D:\\images\\lionstatue.jpg"), FarPoint.Win.RenderStyle.Stretch);
t.BackgroundImage = p;
// Apply the text cell.
fpSpread1.ActiveSheet.Cells[1, 1].CellType = t;
// Set the size of the cell so the image is displayed
fpSpread1.ActiveSheet.Rows[1].Height = 50;
fpSpread1.ActiveSheet.Columns[1].Width = 150;
}
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
   ' Create an instance of a text cell.
   Dim t As New FarPoint.Win.Spread.CellType.TextCellType
   ' Load an image file and set it to BackgroundImage property.
   Dim p As New FarPoint.Win.Picture(Image.FromFile("D:\\images\\lionstatue.jpg"), FarPoint.Win.RenderStyle.Stretch)
   t.BackgroundImage = p
   ' Apply the text cell.
   fpSpread1.ActiveSheet.Cells(1, 1).CellType = t
   ' Set the size of the cell so the image is displayed
   fpSpread1.ActiveSheet.Rows(1).Height = 50
   fpSpread1.ActiveSheet.Columns(1).Width = 150
End Sub

See Also

Setting the Background Colors for a Sheet

Coloring a Cell

Setting a Background Image for a Sheet