DataGridViewAutoSizeColumnsMode 열거형

정의

열의 너비를 조정하는 방법을 지정하는 값을 정의합니다.

public enum class DataGridViewAutoSizeColumnsMode
public enum DataGridViewAutoSizeColumnsMode
type DataGridViewAutoSizeColumnsMode = 
Public Enum DataGridViewAutoSizeColumnsMode
상속
DataGridViewAutoSizeColumnsMode

필드

AllCells 6

머리글 셀을 포함하여 열에 있는 모든 셀의 내용에 맞도록 열 너비가 조정됩니다.

AllCellsExceptHeader 4

머리글 셀을 제외하고 열에 있는 모든 셀의 내용에 맞도록 열 너비가 조정됩니다.

ColumnHeader 2

열 머리글 셀의 내용에 맞도록 열 너비가 조정됩니다.

DisplayedCells 10

머리글 셀을 포함하여 현재 화면에 표시된 행의 열에 있는 모든 셀의 내용에 맞도록 열 너비가 조정됩니다.

DisplayedCellsExceptHeader 8

머리글 셀을 제외하고 현재 화면에 표시된 행의 열에 있는 모든 셀의 내용에 맞도록 열 너비가 조정됩니다.

Fill 16

모든 열의 너비가 컨트롤의 표시 영역을 정확히 채우도록 열 너비가 조정됩니다. MinimumWidth 속성 값 이상으로 열 너비를 유지해야 할 경우에만 가로 스크롤이 필요합니다. 상대 열 너비는 상대 FillWeight 속성 값에 의해 결정됩니다.

None 1

열 너비가 자동으로 조정되지 않습니다.

예제

다음 코드 예제에서는 두 개의 마스터/세부 정보 시나리오에서이 열거형의 사용을 보여 줍니다 DataGridView 컨트롤이 부모/자식 관계에서 두 테이블에서 데이터를 표시 합니다. 이 예제에서는 마스터 컨트롤에 대 한 열 크기 조정 모드가 None이 고 열 너비 로드 된 값에 맞게 프로그래밍 방식으로 초기화 됩니다. 세부 컨트롤 (예를 들어 사용자가 변경할 때 부모 테이블의 현재 행) 값이 변경 될 때마다 열이 자동으로 조정 되도록 자동 크기 조정 모드로 설정 됩니다. 이 예제는에서 사용할 수 있는 보다 큰 예제의 일부 방법:는 마스터/세부 폼 사용 하 여 두 개의 Windows Forms DataGridView 컨트롤 만들기합니다.

private void Form1_Load(object sender, System.EventArgs e)
{
    // Bind the DataGridView controls to the BindingSource
    // components and load the data from the database.
    masterDataGridView.DataSource = masterBindingSource;
    detailsDataGridView.DataSource = detailsBindingSource;
    GetData();

    // Resize the master DataGridView columns to fit the newly loaded data.
    masterDataGridView.AutoResizeColumns();

    // Configure the details DataGridView so that its columns automatically
    // adjust their widths when the data changes.
    detailsDataGridView.AutoSizeColumnsMode = 
        DataGridViewAutoSizeColumnsMode.AllCells;
}
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) _
    Handles Me.Load

    ' Bind the DataGridView controls to the BindingSource
    ' components and load the data from the database.
    masterDataGridView.DataSource = masterBindingSource
    detailsDataGridView.DataSource = detailsBindingSource
    GetData()

    ' Resize the master DataGridView columns to fit the newly loaded data.
    masterDataGridView.AutoResizeColumns()

    ' Configure the details DataGridView so that its columns automatically
    ' adjust their widths when the data changes.
    detailsDataGridView.AutoSizeColumnsMode = _
        DataGridViewAutoSizeColumnsMode.AllCells

End Sub

설명

DataGridView 컨트롤 컨트롤의 사용 가능한 가로 너비를 채울 수 있도록 하거나 지정 된 셀 또는 셀을 모두의 전체 내용을 표시할 수 있도록 해당 열의 크기를 조정할 수 있습니다.

사용 하 여 Fill 모드, 기본 설정된 너비 열 컨트롤에 표시 되는 모든 열에는 정확 하 게 사용 가능한 표시 영역의 가로 너비를 채우도록 해당 모드에 있는 모든 열의 크기를 조정 하 여 결정 됩니다. 기본 열 너비는 다른 모드를 사용 하 여 현재 표시 된 행에 있는 셀의 하위 집합을 같은 열에 있는 모든 셀 또는 셀의 하위 집합의 가장 큰 셀 값을 표시 하는 데 필요한 최소 너비가입니다. 셀의 하위 집합을 사용 하 여 새 너비를 확인 하는 것은 많은 데이터 행을 작업할 때 성능 저하를 방지 하려면 유용 합니다.

콘텐츠 기반 자동 크기 조정은 사용자를가 마우스로 열 너비를 조정할 수 없습니다. 사용자 크기 조정 가능 채우기 모드에 있지만.

이 열거형은에서 사용 된 DataGridView 제어 AutoSizeColumnsMode 속성 및 AutoResizeColumns 메서드.

크기 조정 모드에 대 한 자세한 내용은 참조 하세요. Windows Forms DataGridView 컨트롤의 크기 조정 옵션합니다. 열 채우기 모드에 대 한 자세한 내용은 참조 특히 Windows Forms DataGridView 컨트롤의 열 채우기 모드합니다.

적용 대상

추가 정보