Share via


DataGridViewComboBoxCell.Items Özellik

Tanım

Açılan listede görüntülenen seçimi temsil eden nesneleri alır.

public:
 virtual property System::Windows::Forms::DataGridViewComboBoxCell::ObjectCollection ^ Items { System::Windows::Forms::DataGridViewComboBoxCell::ObjectCollection ^ get(); };
[System.ComponentModel.Browsable(false)]
public virtual System.Windows.Forms.DataGridViewComboBoxCell.ObjectCollection Items { get; }
[<System.ComponentModel.Browsable(false)>]
member this.Items : System.Windows.Forms.DataGridViewComboBoxCell.ObjectCollection
Public Overridable ReadOnly Property Items As DataGridViewComboBoxCell.ObjectCollection

Özellik Değeri

DataGridViewComboBoxCell.ObjectCollection Seçimi içeren bir.

Öznitelikler

Örnekler

Aşağıdaki kod örneği, bu özelliğe benzer olan özelliğinin DataGridViewComboBoxColumn.Items kullanımını gösterir. Bu örnek, sınıfa genel bakış konusunda bulunan DataGridViewComboBoxColumn daha büyük bir örneğin parçasıdır.

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

Açıklamalar

Bu özellik, şu anda içinde depolanan öğe listesine başvuru almanıza DataGridViewComboBoxCellolanak tanır. Bu başvuruyla öğeleri ekleyebilir, öğeleri kaldırabilir ve koleksiyondaki öğelerin sayısını alabilirsiniz. Koleksiyonla Items gerçekleştirilebilecek görevler hakkında daha fazla bilgi için bkz DataGridViewComboBoxCell.ObjectCollection. .

dizeler öğesine ItemsValueMember eklenirse ve DisplayMember eklenen her dize hem değer hem de görüntü için kullanılacağından ayarlanması gerekmez.

Not

DataGridViewComboBoxCell aynı görüntüleme değerlerine sahip birden çok öğenin kullanımını desteklemez.

DataSource Özellik ayarlandıysa, Items özellik kullanılamaz.

Hücrenin biçimlendirilmiş değeri her zaman koleksiyondaki Items değerlerden biri olmalıdır, aksi takdirde bir hata oluşur ve hücre değeri koleksiyondaki ilk öğeye geri döner. ve DataGridView.CellFormatting olaylarını DataGridView.DataError işleyerek bu davranışı özelleştirebilirsiniz.

Bu özelliğin üst sütunun Items özelliğinin değeri dışında bir değere ayarlanması, satırın paylaşılmayan hale gelmesini ve fazladan bellek ayırmasını zorlar. Satır paylaşımı hakkında daha fazla bilgi için bkz. Windows Forms DataGridView Denetimini Ölçeklendirmeye Yönelik En İyi Yöntemler.

Şunlara uygulanır

Ayrıca bkz.