共用方式為


DataGridViewImageColumn.Description 屬性

定義

取得或設定可描述資料行的影像之字串。

public:
 property System::String ^ Description { System::String ^ get(); void set(System::String ^ value); };
[System.ComponentModel.Browsable(true)]
public string Description { get; set; }
[<System.ComponentModel.Browsable(true)>]
member this.Description : string with get, set
Public Property Description As String

屬性值

資料行影像的文字描述。 預設為 Empty

屬性

例外狀況

CellTemplate 屬性的值是 null

範例

下列程式碼範例示範如何使用 Description 屬性來反映影像配置。 此範例是如何在 Windows Forms DataGridView 控制項中使用影像資料行中較大範例的一部分。

void Stretch( Object^ sender, EventArgs^ e )
{
   System::Collections::IEnumerator^ myEnum = dataGridView1->Columns->GetEnumerator();
   while ( myEnum->MoveNext() )
   {
      DataGridViewImageColumn^ column = safe_cast<DataGridViewImageColumn^>(myEnum->Current);
      column->ImageLayout = DataGridViewImageCellLayout::Stretch;
      column->Description = L"Stretched";
   }
}

void ZoomToImage( Object^ sender, EventArgs^ e )
{
   System::Collections::IEnumerator^ myEnum1 = dataGridView1->Columns->GetEnumerator();
   while ( myEnum1->MoveNext() )
   {
      DataGridViewImageColumn^ column = safe_cast<DataGridViewImageColumn^>(myEnum1->Current);
      column->ImageLayout = DataGridViewImageCellLayout::Zoom;
      column->Description = L"Zoomed";
   }
}

void NormalImage( Object^ sender, EventArgs^ e )
{
   System::Collections::IEnumerator^ myEnum2 = dataGridView1->Columns->GetEnumerator();
   while ( myEnum2->MoveNext() )
   {
      DataGridViewImageColumn^ column = safe_cast<DataGridViewImageColumn^>(myEnum2->Current);
      column->ImageLayout = DataGridViewImageCellLayout::Normal;
      column->Description = L"Normal";
   }
}
private void Stretch(object sender, EventArgs e)
{
    foreach (DataGridViewImageColumn column in
        dataGridView1.Columns)
    {
        column.ImageLayout = DataGridViewImageCellLayout.Stretch;
        column.Description = "Stretched";
    }
}

private void ZoomToImage(object sender, EventArgs e)
{

    foreach (DataGridViewImageColumn column in
        dataGridView1.Columns)
    {
        column.ImageLayout = DataGridViewImageCellLayout.Zoom;
        column.Description = "Zoomed";
    }
}

private void NormalImage(object sender, EventArgs e)
{

    foreach (DataGridViewImageColumn column in
        dataGridView1.Columns)
    {
        column.ImageLayout = DataGridViewImageCellLayout.Normal;
        column.Description = "Normal";
    }
}
Private Sub Stretch(ByVal sender As Object, _
    ByVal e As EventArgs) Handles Button3.Click

    For Each column As DataGridViewImageColumn _
        In dataGridView1.Columns
        column.ImageLayout = DataGridViewImageCellLayout.Stretch
        column.Description = "Stretched image layout"
    Next
End Sub

Private Sub ZoomToImage(ByVal sender As Object, _
    ByVal e As EventArgs) Handles Button4.Click

    For Each column As DataGridViewImageColumn _
        In dataGridView1.Columns
        column.ImageLayout = DataGridViewImageCellLayout.Zoom
        column.Description = "Zoomed image layout"
    Next
End Sub

Private Sub NormalImage(ByVal sender As Object, _
    ByVal e As EventArgs) Handles Button5.Click

    For Each column As DataGridViewImageColumn _
        In dataGridView1.Columns
        column.ImageLayout = DataGridViewImageCellLayout.Normal
        column.Description = "Normal image layout"
    Next
End Sub

備註

您可以使用 Description 屬性來描述 或 Icon 屬性所提供的 Image 影像。 此描述提供影像的可存取替代方案。 此外,當儲存格值複製到剪貼簿時,就會使用描述文字。

取得或設定這個屬性會取得或設定 Description 屬性所 CellTemplate 傳回之物件的 屬性。 設定這個屬性也會設定 Description 資料行中每個儲存格的屬性。 若要覆寫個別儲存格的指定值,請在設定資料行值之後設定儲存格值。

適用於

另請參閱