DataGridViewComboBoxColumn.Sorted DataGridViewComboBoxColumn.Sorted DataGridViewComboBoxColumn.Sorted DataGridViewComboBoxColumn.Sorted Property

定义

获取或设置指示是否对组合框中的项进行了排序的值。Gets or sets a value indicating whether the items in the combo box are sorted.

public:
 property bool Sorted { bool get(); void set(bool value); };
public bool Sorted { get; set; }
member this.Sorted : bool with get, set
Public Property Sorted As Boolean

属性值

如果对组合框进行了排序,则为 true;否则为 falsetrue if the combo box is sorted; otherwise, false. 默认值为 falseThe default is false.

异常

示例

下面的代码示例演示如何使用DataGridViewComboBoxColumn来帮助进行数据输入到TitleOfCourtesy列。The following code example demonstrates how to use a DataGridViewComboBoxColumn to aid in entering data into the TitleOfCourtesy column. 此示例摘自一个更大的示例中提供DataGridViewComboBoxColumn类概述主题。This example is part of a larger example available in the DataGridViewComboBoxColumn class overview topic.

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

注解

获取或设置此属性获取或设置Sorted属性返回的对象CellTemplate属性。Getting or setting this property gets or sets the Sorted property of the object returned by the CellTemplate property. 设置此属性还将设置Sorted属性列中每个单元格。Setting this property also sets the Sorted property of every cell in the column. 若要重写每个单元格的指定的值,设置单元格的值后设置列的值。To override the specified value for individual cells, set the cell values after you set the column value.

适用于

另请参阅