GrapeCity SPREAD for WPF 2.0J
ImageConverter プロパティ

セル値から画像ソースへの変換に使用されるコンバータを取得します。
構文
'Declaration
 
Public Property ImageConverter As IImageSourceConverter
public IImageSourceConverter ImageConverter {get; set;}

プロパティ値

セル値から画像ソースへの変換に使用されるコンバータ。
次のサンプルはImageCellTypeを作成しイメージ・リンクをイメージに変えるためにImageConverterをセットします。
public void CreateImageCell1()
{
    ImageCellType imageCellType1 = new ImageCellType();
    imageCellType1.Stretch = System.Windows.Media.Stretch.UniformToFill;

    //If the Cell.Value is 'http://www.gcpowertools.com.cn/products/img/mr/ImageCell.jpg', 
    //which is an address linked to a image, you can use the following MyImageConverter to represent that image.
    imageCellType1.ImageConverter = new MyImageConverter();

    this._gcSpreadGrid1[0, 0].CellType = imageCellType1;
}
class MyImageConverter : IImageSourceConverter
{
    public System.Windows.Media.ImageSource GetImageSource(object value)
    {
        if (value != null)
        {
            var image = new System.Windows.Media.Imaging.BitmapImage(new Uri(value.ToString(), UriKind.Absolute));
            return image;
        }
        return null;
    }
}
Public Sub CreateImageCell1()
    Dim imageCellType1 As New ImageCellType()
    imageCellType1.Stretch = System.Windows.Media.Stretch.UniformToFill

    'If the Cell.Value is 'http://www.gcpowertools.com.cn/products/img/mr/ImageCell.jpg', 
    'which is an address linked to a image, you can use the following MyImageConverter to represent that image.
    imageCellType1.ImageConverter = New MyImageConverter()

    Me._gcSpreadGrid1(0, 0).CellType = imageCellType1
End Sub
Private Class MyImageConverter
    Implements IImageSourceConverter
    Public Function GetImageSource(value As Object) As System.Windows.Media.ImageSource Implements IImageSourceConverter.GetImageSource
        If value IsNot Nothing Then
            Dim image = New System.Windows.Media.Imaging.BitmapImage(New Uri(value.ToString(), UriKind.Absolute))
            Return image
        End If
        Return Nothing
    End Function
End Class
参照

ImageCellType クラス
ImageCellType メンバ

 

 


Copyright © 2012 GrapeCity inc. All rights reserved.