- List Box. Object Collection Конструкторы
- Определение
- Перегрузки
- ListBox.ObjectCollection(ListBox)
- Параметры
- Исключения
- Комментарии
- Применяется к
- ListBox.ObjectCollection(ListBox, Object[])
- Параметры
- Исключения
- Комментарии
- Применяется к
- ListBox.ObjectCollection(ListBox, ListBox+ObjectCollection)
- Параметры
- Исключения
- List Box. Object Collection Class
- Definition
- Examples
- Remarks
- Constructors
- Properties
- Methods
- Explicit Interface Implementations
- Extension Methods
- Checked List Box. Object Collection Class
- Definition
- Examples
- Remarks
- Constructors
- Properties
- Methods
- Explicit Interface Implementations
- Extension Methods
- Checked List Box. Object Collection Класс
- Определение
- Примеры
- Комментарии
- Конструкторы
- Свойства
- Методы
- Явные реализации интерфейса
- Методы расширения
List Box. Object Collection Конструкторы
Определение
Инициализирует новый экземпляр ListBox.ObjectCollection. Initializes a new instance of ListBox.ObjectCollection.
Перегрузки
Инициализирует новый экземпляр ListBox.ObjectCollection. Initializes a new instance of ListBox.ObjectCollection.
Инициализирует новый экземпляр ListBox.ObjectCollection, содержащий массив объектов. Initializes a new instance of ListBox.ObjectCollection containing an array of objects.
Инициализирует новый экземпляр ListBox.ObjectCollection на основе другого экземпляра ListBox.ObjectCollection. Initializes a new instance of ListBox.ObjectCollection based on another ListBox.ObjectCollection.
ListBox.ObjectCollection(ListBox)
Инициализирует новый экземпляр ListBox.ObjectCollection. Initializes a new instance of ListBox.ObjectCollection.
Параметры
Объект ListBox, которому принадлежит данная коллекция. The ListBox that owns the collection.
Исключения
.NET 5.0 и более поздние версии: owner имеет значение null . .NET 5.0 and later: owner is null .
Комментарии
Нельзя создать экземпляр этого класса, не связав его с ListBox элементом управления. You cannot create an instance of this class without associating it with a ListBox control.
Применяется к
ListBox.ObjectCollection(ListBox, Object[])
Инициализирует новый экземпляр ListBox.ObjectCollection, содержащий массив объектов. Initializes a new instance of ListBox.ObjectCollection containing an array of objects.
Параметры
Объект ListBox, которому принадлежит данная коллекция. The ListBox that owns the collection.
Массив объектов, добавляемых в коллекцию. An array of objects to add to the collection.
Исключения
.NET 5.0 и более поздней версии: Либо owner , либо value имеет значение null . .NET 5.0 and later: Either owner or value is null .
Комментарии
Нельзя создать экземпляр этого класса, не связав его с ListBox элементом управления. You cannot create an instance of this class without associating it with a ListBox control.
Применяется к
ListBox.ObjectCollection(ListBox, ListBox+ObjectCollection)
Инициализирует новый экземпляр ListBox.ObjectCollection на основе другого экземпляра ListBox.ObjectCollection. Initializes a new instance of ListBox.ObjectCollection based on another ListBox.ObjectCollection.
Параметры
Объект ListBox, которому принадлежит данная коллекция. The ListBox that owns the collection.
Объект ListBox.ObjectCollection, содержимое которого копируется в новую коллекцию. A ListBox.ObjectCollection from which the contents are copied to this collection.
Исключения
.NET 5.0 и более поздней версии: Либо owner , либо value имеет значение null . .NET 5.0 and later: Either owner or value is null .
List Box. Object Collection Class
Definition
Represents the collection of items in a ListBox.
Examples
The following code example demonstrates an owner-drawn ListBox by setting the DrawMode property to the OwnerDrawVariable value and handling the DrawItem and MeasureItem events. It also demonstrates setting the BorderStyle and ScrollAlwaysVisible properties and using the AddRange method.
To run this example, paste it into an empty form that imports the System.Drawing namespace and the System.Windows.Forms namespace. Call InitializeOwnerDrawnListBox from the form’s constructor or Load method.
Remarks
The ListBox.ObjectCollection class stores the items displayed in the ListBox. There are two other collections defined within the ListBox class that enable you to determine what items are selected within this collection. The ListBox.SelectedObjectCollection class provides properties and methods for determining what items are selected within the ListBox.ObjectCollection, while the ListBox.SelectedIndexCollection class enables you to determine what indexes within the ListBox.ObjectCollection are selected.
There are a number of ways to add items to the collection. The Add method provides the ability to add a single object to the collection. To add a number of objects to the collection, you create an array of items and assign it to the AddRange method. If you want to insert an object at a specific location within the collection, you can use the Insert method. To remove items, you can use either the Remove method or the RemoveAt method if you know where the item is located within the collection. The Clear method enables you to remove all items from the collection instead of using the Remove method to remove a single item at a time.
You can also manipulate the items of a ListBox by using the DataSource property. If you use the DataSource property to add items to a ListBox, you can view the items in the ListBox using the Items property but you cannot add or remove items from the list using the methods of the ListBox.ObjectCollection.
In addition to methods and properties for adding and removing items, the ListBox.ObjectCollection also provides methods to find items within the collection. The Contains method enables you to determine whether an object is a member of the collection. Once you know that the item is located within the collection, you can use the IndexOf method to determine where the item is located within the collection.
Constructors
Initializes a new instance of ListBox.ObjectCollection.
Initializes a new instance of ListBox.ObjectCollection containing an array of objects.
Properties
Gets the number of items in the collection.
Gets a value indicating whether the collection is read-only.
Gets or sets the item at the specified index within the collection.
Methods
Adds an item to the list of items for a ListBox.
Adds the items of an existing ListBox.ObjectCollection to the list of items in a ListBox.
Adds an array of items to the list of items for a ListBox.
Removes all items from the collection.
Determines whether the specified item is located within the collection.
Copies the entire collection into an existing array of objects at a specified location within the array.
Determines whether the specified object is equal to the current object.
(Inherited from Object)
Returns an enumerator to use to iterate through the item collection.
Serves as the default hash function.
(Inherited from Object)
Gets the Type of the current instance.
(Inherited from Object)
Returns the index within the collection of the specified item.
Inserts an item into the list box at the specified index.
Creates a shallow copy of the current Object.
(Inherited from Object)
Removes the specified object from the collection.
Removes the item at the specified index within the collection.
Returns a string that represents the current object.
(Inherited from Object)
Explicit Interface Implementations
This API supports the product infrastructure and is not intended to be used directly from your code.
Copies the elements of the collection to an array, starting at a particular array index.
For a description of this member, see IsSynchronized.
For a description of this member, see SyncRoot.
This API supports the product infrastructure and is not intended to be used directly from your code.
Adds an object to the ListBox class.
Determines whether the IList contains a specific value.
Determines the index of a specific item in the IList.
Inserts an item to the IList at the specified index.
For a description of this member, see IsFixedSize.
Gets or sets the element at the specified index.
Removes the first occurrence of a specific object from the IList.
Extension Methods
Casts the elements of an IEnumerable to the specified type.
Filters the elements of an IEnumerable based on a specified type.
Checked List Box. Object Collection Class
Definition
Represents the collection of items in a CheckedListBox.
Examples
The following example enumerates the items in the CheckedListBox and checks every other item in the list. The example demonstrates using the Items property to get the CheckedListBox.ObjectCollection to get the Count of items.
The example also demonstrates using the SetItemCheckState and SetItemChecked methods to set the check state of an item. For every other item that is to be checked, SetItemCheckState is called to set the CheckState to Indeterminate , while SetItemChecked is called on the other item to set the checked state to Checked .
Remarks
The collection is accessed from the parent control, CheckedListBox, by the Items property. To create a collection of objects to display in the CheckedListBox control, you can add or remove the items individually by using the Add and Remove methods.
Constructors
Initializes a new instance of the CheckedListBox.ObjectCollection class.
Properties
Gets the number of items in the collection.
(Inherited from ListBox.ObjectCollection)
Gets a value indicating whether the collection is read-only.
(Inherited from ListBox.ObjectCollection)
Gets or sets the item at the specified index within the collection.
(Inherited from ListBox.ObjectCollection)
Methods
Adds an item to the list of items for a ListBox.
(Inherited from ListBox.ObjectCollection)
Adds an item to the list of items for a CheckedListBox, specifying the object to add and whether it is checked.
Adds an item to the list of items for a CheckedListBox, specifying the object to add and the initial checked value.
Adds the items of an existing ListBox.ObjectCollection to the list of items in a ListBox.
(Inherited from ListBox.ObjectCollection)
Adds an array of items to the list of items for a ListBox.
(Inherited from ListBox.ObjectCollection)
Removes all items from the collection.
(Inherited from ListBox.ObjectCollection)
Determines whether the specified item is located within the collection.
(Inherited from ListBox.ObjectCollection)
Copies the entire collection into an existing array of objects at a specified location within the array.
(Inherited from ListBox.ObjectCollection)
Determines whether the specified object is equal to the current object.
(Inherited from Object)
Returns an enumerator to use to iterate through the item collection.
(Inherited from ListBox.ObjectCollection)
Serves as the default hash function.
(Inherited from Object)
Gets the Type of the current instance.
(Inherited from Object)
Returns the index within the collection of the specified item.
(Inherited from ListBox.ObjectCollection)
Inserts an item into the list box at the specified index.
(Inherited from ListBox.ObjectCollection)
Creates a shallow copy of the current Object.
(Inherited from Object)
Removes the specified object from the collection.
(Inherited from ListBox.ObjectCollection)
Removes the item at the specified index within the collection.
(Inherited from ListBox.ObjectCollection)
Returns a string that represents the current object.
(Inherited from Object)
Explicit Interface Implementations
This API supports the product infrastructure and is not intended to be used directly from your code.
Copies the elements of the collection to an array, starting at a particular array index.
(Inherited from ListBox.ObjectCollection)
For a description of this member, see IsSynchronized.
(Inherited from ListBox.ObjectCollection)
For a description of this member, see SyncRoot.
(Inherited from ListBox.ObjectCollection)
This API supports the product infrastructure and is not intended to be used directly from your code.
Adds an object to the ListBox class.
(Inherited from ListBox.ObjectCollection)
Determines whether the IList contains a specific value.
(Inherited from ListBox.ObjectCollection)
Determines the index of a specific item in the IList.
(Inherited from ListBox.ObjectCollection)
Inserts an item to the IList at the specified index.
(Inherited from ListBox.ObjectCollection)
For a description of this member, see IsFixedSize.
(Inherited from ListBox.ObjectCollection)
Gets or sets the element at the specified index.
(Inherited from ListBox.ObjectCollection)
Removes the first occurrence of a specific object from the IList.
(Inherited from ListBox.ObjectCollection)
Extension Methods
Casts the elements of an IEnumerable to the specified type.
Filters the elements of an IEnumerable based on a specified type.
Checked List Box. Object Collection Класс
Определение
Представляет коллекцию элементов в CheckedListBox. Represents the collection of items in a CheckedListBox.
Примеры
В следующем примере перечисляются элементы в CheckedListBox и проверяется каждый элемент в списке. The following example enumerates the items in the CheckedListBox and checks every other item in the list. В примере показано использование Items свойства для получения объекта CheckedListBox.ObjectCollection для получения Count элементов. The example demonstrates using the Items property to get the CheckedListBox.ObjectCollection to get the Count of items.
В примере также демонстрируется использование SetItemCheckState SetItemChecked методов и для задания состояния проверки элемента. The example also demonstrates using the SetItemCheckState and SetItemChecked methods to set the check state of an item. Для каждого другого проверяемого элемента SetItemCheckState вызывается метод, чтобы установить значение CheckState Indeterminate , а SetItemChecked вызывается для другого элемента, чтобы установить состояние Checked равным Checked . For every other item that is to be checked, SetItemCheckState is called to set the CheckState to Indeterminate , while SetItemChecked is called on the other item to set the checked state to Checked .
Комментарии
Доступ к коллекции осуществляется из родительского элемента управления, CheckedListBox по Items свойству. The collection is accessed from the parent control, CheckedListBox, by the Items property. Чтобы создать коллекцию объектов, отображаемых в CheckedListBox элементе управления, можно добавлять или удалять элементы по отдельности с помощью Add Remove методов и. To create a collection of objects to display in the CheckedListBox control, you can add or remove the items individually by using the Add and Remove methods.
Конструкторы
Инициализирует новый экземпляр класса CheckedListBox.ObjectCollection. Initializes a new instance of the CheckedListBox.ObjectCollection class.
Свойства
Возвращает количество элементов в коллекции. Gets the number of items in the collection.
(Унаследовано от ListBox.ObjectCollection)
Возвращает значение, указывающее, является ли коллекция доступной только для чтения. Gets a value indicating whether the collection is read-only.
(Унаследовано от ListBox.ObjectCollection)
Получает или задает элемент, расположенный в коллекции по указанному индексу. Gets or sets the item at the specified index within the collection.
(Унаследовано от ListBox.ObjectCollection)
Методы
Добавляет элемент в список позиций ListBox. Adds an item to the list of items for a ListBox.
(Унаследовано от ListBox.ObjectCollection)
Добавляет элемент в список элементов для CheckedListBox, указывая объект для добавления и наличие у него отметки. Adds an item to the list of items for a CheckedListBox, specifying the object to add and whether it is checked.
Добавляет элемент в список элементов для CheckedListBox, указывая объект для добавления и начальное отмеченное значение. Adds an item to the list of items for a CheckedListBox, specifying the object to add and the initial checked value.
Добавляет элементы существующего ListBox.ObjectCollection в список позиций ListBox. Adds the items of an existing ListBox.ObjectCollection to the list of items in a ListBox.
(Унаследовано от ListBox.ObjectCollection)
Добавляет массив элементов в список позиций ListBox. Adds an array of items to the list of items for a ListBox.
(Унаследовано от ListBox.ObjectCollection)
Удаляет все элементы из коллекции. Removes all items from the collection.
(Унаследовано от ListBox.ObjectCollection)
Определяет, содержится ли указанный элемент в коллекции. Determines whether the specified item is located within the collection.
(Унаследовано от ListBox.ObjectCollection)
Копирует коллекцию целиком в заданное место существующего массива объектов. Copies the entire collection into an existing array of objects at a specified location within the array.
(Унаследовано от ListBox.ObjectCollection)
Определяет, равен ли указанный объект текущему объекту. Determines whether the specified object is equal to the current object.
(Унаследовано от Object)
Возвращает перечислитель для перебора элементов коллекции. Returns an enumerator to use to iterate through the item collection.
(Унаследовано от ListBox.ObjectCollection)
Служит хэш-функцией по умолчанию. Serves as the default hash function.
(Унаследовано от Object)
Возвращает объект Type для текущего экземпляра. Gets the Type of the current instance.
(Унаследовано от Object)
Возвращает индекс указанного элемента в коллекции. Returns the index within the collection of the specified item.
(Унаследовано от ListBox.ObjectCollection)
Вставляет элемент в список по указанному индексу. Inserts an item into the list box at the specified index.
(Унаследовано от ListBox.ObjectCollection)
Создает неполную копию текущего объекта Object. Creates a shallow copy of the current Object.
(Унаследовано от Object)
Удаляет указанный объект из коллекции. Removes the specified object from the collection.
(Унаследовано от ListBox.ObjectCollection)
Удаляет из коллекции элемент по указанному индексу. Removes the item at the specified index within the collection.
(Унаследовано от ListBox.ObjectCollection)
Возвращает строку, представляющую текущий объект. Returns a string that represents the current object.
(Унаследовано от Object)
Явные реализации интерфейса
Этот API поддерживает инфраструктуру продукта и не предназначен для использования непосредственно из программного кода.
Копирует элементы коллекции в массив начиная с определенного индекса в массиве. Copies the elements of the collection to an array, starting at a particular array index.
(Унаследовано от ListBox.ObjectCollection)
Описание этого члена см. в разделе IsSynchronized. For a description of this member, see IsSynchronized.
(Унаследовано от ListBox.ObjectCollection)
Описание этого члена см. в разделе SyncRoot. For a description of this member, see SyncRoot.
(Унаследовано от ListBox.ObjectCollection)
Этот API поддерживает инфраструктуру продукта и не предназначен для использования непосредственно из программного кода.
Добавляет объект в класс ListBox. Adds an object to the ListBox class.
(Унаследовано от ListBox.ObjectCollection)
Определяет, содержит ли коллекция IList указанное значение. Determines whether the IList contains a specific value.
(Унаследовано от ListBox.ObjectCollection)
Определяет индекс заданного элемента коллекции IList. Determines the index of a specific item in the IList.
(Унаследовано от ListBox.ObjectCollection)
Вставляет элемент в список IList по указанному индексу. Inserts an item to the IList at the specified index.
(Унаследовано от ListBox.ObjectCollection)
Описание этого члена см. в разделе IsFixedSize. For a description of this member, see IsFixedSize.
(Унаследовано от ListBox.ObjectCollection)
Возвращает или задает элемент по указанному индексу. Gets or sets the element at the specified index.
(Унаследовано от ListBox.ObjectCollection)
Удаляет первое вхождение указанного объекта из коллекции IList. Removes the first occurrence of a specific object from the IList.
(Унаследовано от ListBox.ObjectCollection)
Методы расширения
Приводит элементы объекта IEnumerable к заданному типу. Casts the elements of an IEnumerable to the specified type.
Выполняет фильтрацию элементов объекта IEnumerable по заданному типу. Filters the elements of an IEnumerable based on a specified type.
Позволяет осуществлять параллельный запрос. Enables parallelization of a query.
Преобразовывает коллекцию IEnumerable в объект IQueryable. Converts an IEnumerable to an IQueryable.