DataGridViewColumnCollection.GetLastColumn(DataGridViewElementStates, DataGridViewElementStates) DataGridViewColumnCollection.GetLastColumn(DataGridViewElementStates, DataGridViewElementStates) DataGridViewColumnCollection.GetLastColumn(DataGridViewElementStates, DataGridViewElementStates) DataGridViewColumnCollection.GetLastColumn(DataGridViewElementStates, DataGridViewElementStates) Method

정의

표시 순서에서 지정된 필터 요구 사항을 충족시키는 마지막 열을 반환합니다.Returns the last column in display order that meets the given filter requirements.

public:
 System::Windows::Forms::DataGridViewColumn ^ GetLastColumn(System::Windows::Forms::DataGridViewElementStates includeFilter, System::Windows::Forms::DataGridViewElementStates excludeFilter);
public System.Windows.Forms.DataGridViewColumn GetLastColumn (System.Windows.Forms.DataGridViewElementStates includeFilter, System.Windows.Forms.DataGridViewElementStates excludeFilter);
member this.GetLastColumn : System.Windows.Forms.DataGridViewElementStates * System.Windows.Forms.DataGridViewElementStates -> System.Windows.Forms.DataGridViewColumn
Public Function GetLastColumn (includeFilter As DataGridViewElementStates, excludeFilter As DataGridViewElementStates) As DataGridViewColumn

매개 변수

includeFilter
DataGridViewElementStates DataGridViewElementStates DataGridViewElementStates DataGridViewElementStates

포함시키기 위해 적용할 필터를 나타내는 DataGridViewElementStates 값의 비트 조합입니다.A bitwise combination of the DataGridViewElementStates values that represent the filter to apply for inclusion.

excludeFilter
DataGridViewElementStates DataGridViewElementStates DataGridViewElementStates DataGridViewElementStates

제외시키기 위해 적용할 필터를 나타내는 DataGridViewElementStates 값의 비트 조합입니다.A bitwise combination of the DataGridViewElementStates values that represent the filter to apply for exclusion.

반환

표시 순서에서 지정된 필터 요구 사항을 충족시키는 마지막 열이고, 이 열이 없으면 null입니다.The last displayed column in display order that meets the given filter requirements, or null if no column is found.

예외

필터 값 중 하나 이상이 DataGridViewElementStates 값의 유효한 비트 조합이 아닌 경우At least one of the filter values is not a valid bitwise combination of DataGridViewElementStates values.

예제

다음 코드 예제에서는 GetLastColumn 마지막 표시 된 열과 첫 번째 표시 된 열을 교환 하는 방법입니다.The following code example uses the GetLastColumn method to swap the last displayed column and the first displayed column.

// Swap the last column with the first.
void Button10_Click( Object^ /*sender*/, EventArgs^ /*args*/ )
{
   DataGridViewColumnCollection^ columnCollection = dataGridView->Columns;
   DataGridViewColumn^ firstDisplayedColumn = columnCollection->GetFirstColumn( DataGridViewElementStates::Visible );
   DataGridViewColumn^ lastDisplayedColumn = columnCollection->GetLastColumn( DataGridViewElementStates::Visible, DataGridViewElementStates::None );
   int firstColumn_sIndex = firstDisplayedColumn->DisplayIndex;
   firstDisplayedColumn->DisplayIndex = lastDisplayedColumn->DisplayIndex;
   lastDisplayedColumn->DisplayIndex = firstColumn_sIndex;
}


// Swap the last column with the first.
private void Button10_Click(object sender, EventArgs args)
{
    DataGridViewColumnCollection columnCollection = dataGridView.Columns;

    DataGridViewColumn firstVisibleColumn =
        columnCollection.GetFirstColumn(DataGridViewElementStates.Visible);
    DataGridViewColumn lastVisibleColumn =
        columnCollection.GetLastColumn(
            DataGridViewElementStates.Visible, DataGridViewElementStates.None);

    int firstColumn_sIndex = firstVisibleColumn.DisplayIndex;
    firstVisibleColumn.DisplayIndex = lastVisibleColumn.DisplayIndex;
    lastVisibleColumn.DisplayIndex = firstColumn_sIndex;
}
' Swap the last column with the first.
Private Sub Button10_Click(ByVal sender As Object, _
    ByVal args As EventArgs) Handles Button10.Click

    Dim columnCollection As DataGridViewColumnCollection = _
        dataGridView.Columns

    Dim firstVisibleColumn As DataGridViewColumn = _
        columnCollection.GetFirstColumn(DataGridViewElementStates.Visible)
    Dim lastVisibleColumn As DataGridViewColumn = _
        columnCollection.GetLastColumn(DataGridViewElementStates.Visible, _
        Nothing)

    Dim firstColumn_sIndex As Integer = firstVisibleColumn.DisplayIndex
    firstVisibleColumn.DisplayIndex = _
        lastVisibleColumn.DisplayIndex
    lastVisibleColumn.DisplayIndex = firstColumn_sIndex
End Sub

설명

표시 순서에서 마지막 열은 가장 높은 열 DisplayIndex 열이 화면에 실제로 표시 되는지 여부에 관계 없이 값입니다.The last column in display order is the column with the highest DisplayIndex value, regardless of whether the column is actually visible on the screen.

이 메서드를 사용 하면 인덱스 값을 직접 비교할 필요 없이 지정된 된 조건에 맞는 마지막 열을 확인할 수 있습니다.This method lets you determine the last column that fits the given criteria without having to compare index values directly.

적용 대상

추가 정보