DataGridViewCell.ToolTipText 속성

정의

이 셀과 연결된 도구 설명 텍스트를 가져오거나 설정합니다.

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

속성 값

셀과 연결된 도구 설명 텍스트입니다. 기본값은 Empty입니다.

특성

예제

다음 코드 예제를 설정 ToolTipText 하는 방법을 보여 주는 이벤트 처리기 내에서 속성을 이벤트입니다 CellFormatting . 이 예제는 방법: Windows Forms DataGridView 컨트롤의 개별 셀에 도구 설명 추가에 제공된 더 큰 코드 예제의 일부입니다.

// Sets the ToolTip text for cells in the Rating column.
void dataGridView1_CellFormatting(Object^ /*sender*/, 
    DataGridViewCellFormattingEventArgs^ e)
{
    if ( (e->ColumnIndex == this->dataGridView1->Columns["Rating"]->Index)
        && e->Value != nullptr )
    {
        DataGridViewCell^ cell = 
            this->dataGridView1->Rows[e->RowIndex]->Cells[e->ColumnIndex];
        if (e->Value->Equals("*"))
        {                
            cell->ToolTipText = "very bad";
        }
        else if (e->Value->Equals("**"))
        {
            cell->ToolTipText = "bad";
        }
        else if (e->Value->Equals("***"))
        {
            cell->ToolTipText = "good";
        }
        else if (e->Value->Equals("****"))
        {
            cell->ToolTipText = "very good";
        }
    }
}
// Sets the ToolTip text for cells in the Rating column.
void dataGridView1_CellFormatting(object sender, 
    DataGridViewCellFormattingEventArgs e)
{
    if ( (e.ColumnIndex == this.dataGridView1.Columns["Rating"].Index)
        && e.Value != null )
    {
        DataGridViewCell cell = 
            this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex];
        if (e.Value.Equals("*"))
        {                
            cell.ToolTipText = "very bad";
        }
        else if (e.Value.Equals("**"))
        {
            cell.ToolTipText = "bad";
        }
        else if (e.Value.Equals("***"))
        {
            cell.ToolTipText = "good";
        }
        else if (e.Value.Equals("****"))
        {
            cell.ToolTipText = "very good";
        }
    }
}
' Sets the ToolTip text for cells in the Rating column.
Sub dataGridView1_CellFormatting(ByVal sender As Object, _
    ByVal e As DataGridViewCellFormattingEventArgs) _
    Handles dataGridView1.CellFormatting

    If e.ColumnIndex = Me.dataGridView1.Columns("Rating").Index _
        AndAlso (e.Value IsNot Nothing) Then

        With Me.dataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex)

            If e.Value.Equals("*") Then
                .ToolTipText = "very bad"
            ElseIf e.Value.Equals("**") Then
                .ToolTipText = "bad"
            ElseIf e.Value.Equals("***") Then
                .ToolTipText = "good"
            ElseIf e.Value.Equals("****") Then
                .ToolTipText = "very good"
            End If

        End With

    End If

End Sub

설명

마우스 포인터가 셀 위에 있고 속성 값이 이 아닌 Empty경우 이 속성의 값은 도구 설명 셀로 표시됩니다. 이 속성의 값이 Empty이면 셀 표시에서 값이 잘린 경우 셀 값이 포함된 도구 설명이 셀에 표시됩니다. 그렇지 않으면 셀에 도구 설명이 표시되지 않습니다. 속성을 로 설정하여 도구 설명의 표시를 DataGridView.ShowCellToolTips 방지할 수도 있습니다 false.

컨트롤 속성이 DataGridView 설정되거나 해당 VirtualMode 속성이 이true면 속성 값을 ToolTipText 가져오면 컨트롤의 이벤트가 발생 CellToolTipTextNeeded 하며 이벤트 처리기에 지정된 대로 속성의 DataGridViewCellToolTipTextNeededEventArgs.ToolTipText 값이 반환 DataSource 됩니다. 이벤트에 대한 처리기가 없으면 속성의 ToolTipText 값을 가져오면 이전에 지정한 값 또는 의 기본값 Empty이 반환됩니다.

이벤트 처리는 여러 셀에 CellToolTipTextNeeded 대한 셀 ToolTipText 값을 설정할 때 성능 저하를 방지하기 위해 많은 양의 데이터를 사용할 때 주로 유용합니다. 자세한 내용은 Windows Forms DataGridView 컨트롤의 크기를 조정하는 최선의 방법을 참조하세요.

이 속성을 변경하면 소유 DataGridView중인 에 이벤트가 발생 CellToolTipTextChanged 합니다(있는 경우).

적용 대상

추가 정보