DataGridViewImageColumn.Image 屬性

定義

當未設定儲存格的 Value 屬性且儲存格的 ValueIsIcon 屬性設定為 false 時,取得或設定此資料行的儲存格內所顯示的影像。

public:
 property System::Drawing::Image ^ Image { System::Drawing::Image ^ get(); void set(System::Drawing::Image ^ value); };
public System.Drawing.Image Image { get; set; }
member this.Image : System.Drawing.Image with get, set
Public Property Image As Image

屬性值

Image

要顯示的 Image。 預設為 null

範例

下列程式碼範例示範如何設定預設映射。 此範例是如何在 Windows Forms DataGridView 控制項中使用影像資料行中較大範例的一部分。

void CreateColumns()
{
   DataGridViewImageColumn^ imageColumn;
   int columnCount = 0;
   do
   {
      Bitmap^ unMarked = blank;
      imageColumn = gcnew DataGridViewImageColumn;
      
      //Add twice the padding for the left and 
      //right sides of the cell.
      imageColumn->Width = x->Width + 2 * bitmapPadding + 1;
      imageColumn->Image = unMarked;
      dataGridView1->Columns->Add( imageColumn );
      columnCount = columnCount + 1;
   }
   while ( columnCount < 3 );
}
private void CreateColumns()
{
    DataGridViewImageColumn imageColumn;
    int columnCount = 0;
    do
    {
        Bitmap unMarked = blank;
        imageColumn = new DataGridViewImageColumn();

        //Add twice the padding for the left and 
        //right sides of the cell.
        imageColumn.Width = x.Width + 2 * bitmapPadding + 1;

        imageColumn.Image = unMarked;
        dataGridView1.Columns.Add(imageColumn);
        columnCount = columnCount + 1;
    }
    while (columnCount < 3);
}
Private Sub CreateColumns()

    Dim imageColumn As DataGridViewImageColumn
    Dim columnCount As Integer = 0
    Do
        Dim unMarked As Bitmap = blank
        imageColumn = New DataGridViewImageColumn()

        ' Add twice the padding for the left and 
        ' right sides of the cell.
        imageColumn.Width = x.Width + 2 * bitmapPadding + 1

        imageColumn.Image = unMarked
        imageColumn.ImageLayout = DataGridViewImageCellLayout.NotSet
        imageColumn.Description = "default image layout"
        dataGridView1.Columns.Add(imageColumn)
        columnCount = columnCount + 1
    Loop While columnCount < 3
End Sub

備註

屬性 Image 會指定當資料行未系結且儲存格 ValueIsIcon 的 屬性設定 false 為 時,沒有值的儲存格中顯示的影像。 如果是儲存格沒有相關聯影像的資料系結資料行,則會顯示標準錯誤圖形。

如果您想要顯示 Icon 而非 Image ,請改為設定 屬性, Icon 並將 屬性設定 ValuesAreIconstrue 。 這可確保 的 Alpha 色板 Icon 正確繪製。 您也可以設定 ValueIsIcon 個別儲存格的 屬性,以指出儲存格在沒有儲存格值時,是否顯示 ImageIcon 屬性值。

適用於

另請參閱