DataGridViewBand.Selected 속성

정의

밴드가 선택한 사용자 인터페이스 (UI) 상태 인지 여부를 나타내는 값을 가져오거나 설정 합니다.Gets or sets a value indicating whether the band is in a selected user interface (UI) state.

public:
 virtual property bool Selected { bool get(); void set(bool value); };
[System.ComponentModel.Browsable(false)]
public virtual bool Selected { get; set; }
member this.Selected : bool with get, set
Public Overridable Property Selected As Boolean

속성 값

밴드가 선택되어 있으면 true이고, 그렇지 않으면 false입니다.true if the band is selected; otherwise, false.

특성

예외

이 속성을 설정할 때 지정된 값이 true이지만 밴드가 DataGridView 컨트롤에 추가되지 않은 경우The specified value when setting this property is true, but the band has not been added to a DataGridView control.

-또는--or- 이 속성이 공유 DataGridViewRow에 설정되고 있는 경우This property is being set on a shared DataGridViewRow.

예제

다음 코드 예제에서는이 속성의 사용을 보여 줍니다.The following code example illustrates the use of this property.

void dataGridView1_ColumnHeaderMouseClick(
    object sender, DataGridViewCellMouseEventArgs e)
{
    this.dataGridView1.SelectionMode =
        DataGridViewSelectionMode.ColumnHeaderSelect;
    this.dataGridView1.Columns[e.ColumnIndex].HeaderCell
        .SortGlyphDirection = SortOrder.None;
    this.dataGridView1.Columns[e.ColumnIndex].Selected = true;
}

void dataGridView1_RowHeaderMouseClick(
    object sender, DataGridViewCellMouseEventArgs e)
{
    this.dataGridView1.SelectionMode =
        DataGridViewSelectionMode.RowHeaderSelect;
    this.dataGridView1.Rows[e.RowIndex].Selected = true;
}
Private Sub dataGridView1_ColumnHeaderMouseClick( _
    ByVal sender As Object, ByVal e As DataGridViewCellMouseEventArgs) _
    Handles dataGridView1.ColumnHeaderMouseClick

    Me.dataGridView1.SelectionMode = _
        DataGridViewSelectionMode.ColumnHeaderSelect
    Me.dataGridView1.Columns(e.ColumnIndex).HeaderCell _
        .SortGlyphDirection = SortOrder.None
    Me.dataGridView1.Columns(e.ColumnIndex).Selected = True

End Sub

Private Sub dataGridView1_RowHeaderMouseClick( _
    ByVal sender As Object, ByVal e As DataGridViewCellMouseEventArgs) _
    Handles dataGridView1.RowHeaderMouseClick

    Me.dataGridView1.SelectionMode = _
        DataGridViewSelectionMode.RowHeaderSelect
    Me.dataGridView1.Rows(e.RowIndex).Selected = True

End Sub

설명

이 속성은 SelectionMode 속성을 사용 하는 DataGridView 밴드와 연결 된 경우에만 설정할 수 있습니다.This property can be set only if a DataGridView with the SelectionMode property enabled is associated with the band.

적용 대상

추가 정보