DataGridViewImageColumn.Description DataGridViewImageColumn.Description DataGridViewImageColumn.Description DataGridViewImageColumn.Description Property

定義

取得或設定可描述資料行的影像之字串。Gets or sets a string that describes the column's image.

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

屬性值

資料行影像的文字描述。The textual description of the column image. 預設為 EmptyThe default is Empty.

例外狀況

範例

下列程式碼範例示範如何使用Description屬性來反映影像版面配置。The following code example demonstrates how to use the Description property to reflect the image layout. 這個範例是中所提供之較大範例的一部分。使用 Windows Forms DataGridView 控制項中的影像資料行。This example is part of a larger example available in How to: Work with Image Columns in the Windows Forms DataGridView Control.

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屬性來描述ImageIcon屬性所提供的影像。You can use the Description property to describe the image provided by the Image or Icon property. 此描述提供影像的可存取替代方案。This description provides an accessible alternative to the image. 此外, 當資料格的值複製到剪貼簿時, 會使用描述文字。Additionally, the description text is used when the cell value is copied onto the Clipboard.

取得或設定這個屬性會取得或設定Description CellTemplate屬性所傳回之物件的屬性。Getting or setting this property gets or sets the Description property of the object returned by the CellTemplate property. 設定這個屬性也會設定Description資料行中每個資料格的屬性。Setting this property also sets the Description property of every cell in the column. 若要覆寫個別儲存格的指定值, 請在設定資料行值之後設定儲存格值。To override the specified value for individual cells, set the cell values after you set the column value.

適用於

另請參閱