DataGridViewComboBoxColumn.MaxDropDownItems Eigenschap

Definitie

Hiermee haalt u het maximum aantal items op of stelt u dit in de vervolgkeuzelijst van de cellen in de kolom in.

public:
 property int MaxDropDownItems { int get(); void set(int value); };
public int MaxDropDownItems { get; set; }
member this.MaxDropDownItems : int with get, set
Public Property MaxDropDownItems As Integer

Waarde van eigenschap

Het maximum aantal vervolgkeuzelijstitems, van 1 tot 100. De standaardwaarde is 8.

Uitzonderingen

De waarde van de CellTemplate eigenschap is null.

Voorbeelden

In het volgende codevoorbeeld ziet u hoe u een DataGridViewComboBoxColumn voorbeeld gebruikt om gegevens in de kolom in te TitleOfCourtesy voeren. Dit voorbeeld maakt deel uit van een groter voorbeeld dat beschikbaar is in het overzichtsonderwerp van de DataGridViewComboBoxColumn klas.

private:
    void SetAlternateChoicesUsingItems(
        DataGridViewComboBoxColumn^ comboboxColumn)
    {
        comboboxColumn->Items->AddRange("Mr.", "Ms.", "Mrs.", "Dr.");
    }

private:
    DataGridViewComboBoxColumn^ CreateComboBoxColumn()
    {
        DataGridViewComboBoxColumn^ column =
            gcnew DataGridViewComboBoxColumn();
        {
            column->DataPropertyName = ColumnName::TitleOfCourtesy.ToString();
            column->HeaderText = ColumnName::TitleOfCourtesy.ToString();
            column->DropDownWidth = 160;
            column->Width = 90;
            column->MaxDropDownItems = 3;
            column->FlatStyle = FlatStyle::Flat;
        }
        return column;
    }
private static void SetAlternateChoicesUsingItems(
    DataGridViewComboBoxColumn comboboxColumn)
{
    comboboxColumn.Items.AddRange("Mr.", "Ms.", "Mrs.", "Dr.");
}

private DataGridViewComboBoxColumn CreateComboBoxColumn()
{
    DataGridViewComboBoxColumn column =
        new DataGridViewComboBoxColumn();
    {
        column.DataPropertyName = ColumnName.TitleOfCourtesy.ToString();
        column.HeaderText = ColumnName.TitleOfCourtesy.ToString();
        column.DropDownWidth = 160;
        column.Width = 90;
        column.MaxDropDownItems = 3;
        column.FlatStyle = FlatStyle.Flat;
    }
    return column;
}
Private Shared Sub SetAlternateChoicesUsingItems( _
    ByVal comboboxColumn As DataGridViewComboBoxColumn)

    comboboxColumn.Items.AddRange("Mr.", "Ms.", "Mrs.", "Dr.")

End Sub

Private Function CreateComboBoxColumn() _
    As DataGridViewComboBoxColumn
    Dim column As New DataGridViewComboBoxColumn()

    With column
        .DataPropertyName = ColumnName.TitleOfCourtesy.ToString()
        .HeaderText = ColumnName.TitleOfCourtesy.ToString()
        .DropDownWidth = 160
        .Width = 90
        .MaxDropDownItems = 3
        .FlatStyle = FlatStyle.Flat
    End With
    Return column
End Function

Opmerkingen

Als u deze eigenschap ophaalt of instelt, wordt de MaxDropDownItems eigenschap van het object dat door de CellTemplate eigenschap wordt geretourneerd, opgehaald of ingesteld. Als u deze eigenschap instelt, wordt ook de MaxDropDownItems eigenschap van elke cel in de kolom ingesteld. Als u de opgegeven waarde voor afzonderlijke cellen wilt overschrijven, stelt u de celwaarden in nadat u de kolomwaarde hebt ingesteld.

Van toepassing op

Zie ook