GrapeCity SPREAD for Windows Forms 11.0J サンプルコード集
背景画像を設定する

各セル型クラスからは背景画像を設定するBackgroundImageプロパティが提供されているため、指定した画像ファイルを読み込んで表示させることができます。ここではテキスト型セルを用いた例を紹介します。

【実行例】

背景画像の設定

  • セルの編集時、設定した背景画像は表示されません。
  • Excelファイルへのエクスポート時、背景画像は出力されません。

 private void Form1_Load(object sender, System.EventArgs e)
 {

  //テキスト型セルのインスタンスを作成します
  FarPoint.Win.Spread.CellType.TextCellType t = new FarPoint.Win.Spread.CellType.TextCellType();

  //画像ファイルを読み込み、BackgroundImageプロパティに設定します
  FarPoint.Win.Picture p = new FarPoint.Win.Picture(Image.FromFile("画像ファイルパス名"), FarPoint.Win.RenderStyle.Stretch);
  t.BackgroundImage = p;

  //テキスト型セルを設定します
  fpSpread1.ActiveSheet.Cells[1, 1].CellType = t;

  fpSpread1.ActiveSheet.Rows[1].Height = 34;
  fpSpread1.ActiveSheet.Columns[1].Width = 180;

 }
 Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load

  'テキスト型セルのインスタンスを作成します
  Dim t As New FarPoint.Win.Spread.CellType.TextCellType

  '画像ファイルを読み込み、BackgroundImageプロパティに設定します
  Dim p As New FarPoint.Win.Picture(Image.FromFile("画像ファイルパス名"), FarPoint.Win.RenderStyle.Stretch)
  t.BackgroundImage = p

  'テキスト型セルを設定します
  FpSpread1.ActiveSheet.Cells(1, 1).CellType = t

  FpSpread1.ActiveSheet.Rows(1).Height = 34
  FpSpread1.ActiveSheet.Columns(1).Width = 180

 End Sub

 

 


© 2004-2018, GrapeCity inc. All rights reserved.