Spread Windows Forms 10.0 Product Documentation
Setting a Background Image to a Cell

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

Cell with Background Image

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.

C#
Copy Code
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;
} 
VB
Copy Code
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

 

 


Copyright © GrapeCity, inc. All rights reserved.

Support Options | Documentation Feedback