[]
イメージ型セルはセルに画像を表示します。ImageCellType クラスを使用して設定します。
!type=note
メモ:デザイナを使用した設定方法については、「イメージ型セルの設定」をご覧ください。

主な設定は次のとおりです。
イメージ型セルの値は画像のソースを表す ImageSource または画像を表すバイナリ データであることが求められます。たとえば、セルの値がイメージ ファイルへのパスを表す文字列である場合があります。このようにセルの値が ImageSource 型、または画像を表すバイナリ データでない場合、値を ImageSource に変換する ImageConverter を設定することで対応できます。
ImageConverter は IImageSourceConverter インタフェースを実装して作成します。
次のサンプルコードはアプリケーションの img フォルダーに保存された SpreadPicture.png ファイルをイメージ型セルに読み込みます。SpreadFilePathToImageConverter クラスが、ファイル パスを BitmapImage に変換します。
サンプルコード
ImageCellType img = new ImageCellType();
img.ImageConverter = new SpreadFilePathToImageConverter();
gcSpreadGrid1[0, 3].CellType = img;
gcSpreadGrid1[0, 3].Value = "img/SpreadPicture.png";public class SpreadFilePathToImageConverter : IImageSourceConverter
{
public ImageSource GetImageSource(object value)
{
if (value != null)
{
BitmapImage bmi = new BitmapImage(new Uri(value.ToString(), UriKind.Relative));
return bmi;
}
else return null;
}
}Dim img As New ImageCellType()
img.ImageConverter = New SpreadFilePathToImageConverter()
GcSpreadGrid1(0, 3).CellType = img
GcSpreadGrid1(0, 3).Value = "img/SpreadPicture.png"Public Class SpreadFilePathToImageConverter
Implements IImageSourceConverter
Public Function GetImageSource(value As Object) As ImageSource Implements IImageSourceConverter.GetImageSource
If value IsNot Nothing Then
Dim bmi As New BitmapImage(New Uri(value.ToString(), UriKind.Relative))
Return bmi
Else
Return Nothing
End If
End Function
End ClassStretch プロパティで設定します。