System windows forms treenodecollection

Tree Node Collection. Add Range(TreeNode[]) Метод

Определение

Добавляет в коллекцию массив предварительно созданных узлов дерева. Adds an array of previously created tree nodes to the collection.

Параметры

Массив объектов TreeNode, предоставляющий узлы дерева, добавляемые в коллекцию. An array of TreeNode objects representing the tree nodes to add to the collection.

Исключения

nodes имеет значение null . nodes is null .

Объект nodes является дочерним объектом другого элемента управления TreeView. nodes is the child of another TreeView.

Примеры

В следующем примере кода производится копирование TreeNodeCollection из в TreeView временный объект Array , а затем содержимое массива добавляется в другой TreeView с помощью AddRange метода. The following code example copies the TreeNodeCollection from a TreeView to a temporary Array, and then adds the contents of the array to another TreeView using the AddRange method. TreeNodeCollectionИз источника удаляется TreeView с помощью Clear метода. The TreeNodeCollection from the source TreeView is cleared using the Clear method. В этом примере предполагается, что у вас есть два TreeView элемента управления: один с коллекцией TreeNode объектов. This example requires that you have two TreeView controls, one with a collection of TreeNode objects.

Комментарии

TreeNodeОбъекты, содержащиеся в nodes массиве, добавляются в конец коллекции. The TreeNode objects contained in the nodes array are appended to the end of the collection.

Метод можно использовать AddRange для быстрого добавления группы ранее созданных TreeNode объектов в коллекцию вместо того, чтобы вручную добавлять их TreeNode в коллекцию с помощью Add метода. You can use the AddRange method to quickly add a group of previously created TreeNode objects to the collection instead of manually adding each TreeNode to the collection using the Add method.

Чтобы удалить TreeNode добавленный ранее объект, используйте Remove RemoveAt методы, или Clear . To remove a TreeNode that you previously added, use the Remove, RemoveAt, or Clear methods.

Tree Node Collection Класс

Определение

Представляет коллекцию объектов TreeNode. Represents a collection of TreeNode objects.

Примеры

В следующем примере кода отображаются сведения о клиенте в TreeView элементе управления. The following code example displays customer information in a TreeView control. Узлы корневого дерева отображают имена клиентов, а дочерние узлы дерева отображают номера заказов, назначенные каждому клиенту. The root tree nodes display customer names, and the child tree nodes display the order numbers assigned to each customer. В этом примере 1 000 клиентов отображаются с 15 заказами. In this example, 1,000 customers are displayed with 15 orders each. Перерисовка TreeView отключается с помощью BeginUpdate EndUpdate методов и, а Cursor во время TreeView создания и прорисовки объектов отображается ожидание TreeNode . The repainting of the TreeView is suppressed by using the BeginUpdate and EndUpdate methods, and a wait Cursor is displayed while the TreeView creates and paints the TreeNode objects. В этом примере требуется Customer объект, который может содержать коллекцию Order объектов. This example requires that you have a Customer object that can hold a collection of Order objects. Также необходимо создать экземпляр TreeView элемента управления в Form . It also requires that you have created an instance of a TreeView control on a Form.

Комментарии

AddМетоды, Remove и RemoveAt позволяют добавлять и удалять отдельные узлы дерева из коллекции. The Add, Remove, and RemoveAt methods enable you to add and remove individual tree nodes from the collection.

Перечисление коллекции и удаление узлов не поддерживается. Enumerating the collection and removing nodes is not supported.

Можно также использовать AddRange Clear методы или для добавления или удаления всех узлов дерева из коллекции. You can also use the AddRange or Clear methods to add or remove all the tree nodes from the collection.

Классы не могут наследовать от TreeNodeCollection класса. Classes cannot inherit from the TreeNodeCollection class.

Свойства

Возвращает общее число объектов TreeNode в коллекции. Gets the total number of TreeNode objects in the collection.

Возвращает значение, указывающее, является ли коллекция доступной только для чтения. Gets a value indicating whether the collection is read-only.

Получает или задает объект TreeNode по указанному индексу в коллекции. Gets or sets the TreeNode at the specified indexed location in the collection.

Возвращает узел дерева с указанным ключом из коллекции. Gets the tree node with the specified key from the collection.

Методы

Добавляет новый узел дерева с заданным текстом метки в конец текущей коллекции узлов дерева. Adds a new tree node with the specified label text to the end of the current tree node collection.

Создает новый узел дерева с указанным ключом и текстом и добавляет его в коллекцию. Creates a new tree node with the specified key and text, and adds it to the collection.

Создает узел дерева с указанным ключом, текстом и изображением и добавляет его в коллекцию. Creates a tree node with the specified key, text, and image, and adds it to the collection.

Создает узел дерева с указанным ключом, текстом и изображениями и добавляет его в коллекцию. Creates a tree node with the specified key, text, and images, and adds it to the collection.

Создает узел дерева с указанным ключом, текстом и изображением и добавляет его в коллекцию. Creates a tree node with the specified key, text, and image, and adds it to the collection.

Создает узел дерева с указанным ключом, текстом и изображениями и добавляет его в коллекцию. Creates a tree node with the specified key, text, and images, and adds it to the collection.

Добавляет ранее созданный узел дерева в конец коллекции узлов дерева. Adds a previously created tree node to the end of the tree node collection.

Читайте также:  A4tech pk 930ha linux

Добавляет в коллекцию массив предварительно созданных узлов дерева. Adds an array of previously created tree nodes to the collection.

Удаляет все узлы дерева из коллекции. Removes all tree nodes from the collection.

Определяет, является ли указанный узел дерева членом коллекции. Determines whether the specified tree node is a member of the collection.

Определяет, содержится ли в коллекции узел дерева с указанным ключом. Determines whether the collection contains a tree node with the specified key.

Копирует коллекцию целиком в заданное место существующего массива. Copies the entire collection into an existing array at a specified location within the array.

Определяет, равен ли указанный объект текущему объекту. Determines whether the specified object is equal to the current object.

(Унаследовано от Object) Find(String, Boolean)

Осуществляет поиск узлов дерева с заданным ключом, при необходимости просматривая вложенные узлы. Finds the tree nodes with specified key, optionally searching subnodes.

Возвращает перечислитель, который может использоваться для просмотра всех элементов коллекции узлов дерева. Returns an enumerator that can be used to iterate through the tree node collection.

Служит хэш-функцией по умолчанию. Serves as the default hash function.

(Унаследовано от Object) GetType()

Возвращает объект Type для текущего экземпляра. Gets the Type of the current instance.

(Унаследовано от Object) IndexOf(TreeNode)

Возвращает индекс указанного узла дерева в коллекции. Returns the index of the specified tree node in the collection.

Возвращает индекс первого вхождения элемента узла с указанным ключом. Returns the index of the first occurrence of a tree node with the specified key.

Создает узел дерева с указанным текстом и вставляет его по указанному индексу. Creates a tree node with the specified text and inserts it at the specified index.

Создает узел дерева с указанным текстом и ключом и вставляет его в коллекцию. Creates a tree node with the specified text and key, and inserts it into the collection.

Создает узел дерева с указанным ключом, текстом и изображением и вставляет его в коллекцию по указанному индексу. Creates a tree node with the specified key, text, and image, and inserts it into the collection at the specified index.

Создает узел дерева с указанным ключом, текстом и изображениями и вставляет его в коллекцию по указанному индексу. Creates a tree node with the specified key, text, and images, and inserts it into the collection at the specified index.

Создает узел дерева с указанным ключом, текстом и изображением и вставляет его в коллекцию по указанному индексу. Creates a tree node with the specified key, text, and image, and inserts it into the collection at the specified index.

Создает узел дерева с указанным ключом, текстом и изображениями и вставляет его в коллекцию по указанному индексу. Creates a tree node with the specified key, text, and images, and inserts it into the collection at the specified index.

Вставляет существующий узел дерева в заданную позицию коллекции узлов дерева. Inserts an existing tree node into the tree node collection at the specified location.

Создает неполную копию текущего объекта Object. Creates a shallow copy of the current Object.

(Унаследовано от Object) Remove(TreeNode)

Удаляет указанный узел дерева из коллекции узлов дерева. Removes the specified tree node from the tree node collection.

Удаляет узел дерева из заданной индексом позиции коллекции узлов дерева. Removes a tree node from the tree node collection at a specified index.

Удаляет узел дерева с указанным ключом из коллекции. Removes the tree node with the specified key from the collection.

Возвращает строку, представляющую текущий объект. Returns a string that represents the current object.

(Унаследовано от Object)

Явные реализации интерфейса

Возвращает значение, указывающее, является ли доступ к коллекции синхронизированным (потокобезопасным). Gets a value indicating whether access to the collection is synchronized (thread safe).

Возвращает объект, который можно использовать для синхронизации доступа к коллекции. Gets an object that can be used to synchronize access to the collection.

Добавляет объект в конец коллекции узлов дерева. Adds an object to the end of the tree node collection.

Определяет, является ли указанный узел дерева членом коллекции. Determines whether the specified tree node is a member of the collection.

Возвращает индекс указанного узла дерева в коллекции. Returns the index of the specified tree node in the collection.

Вставляет существующий узел дерева на заданную позицию в коллекцию узлов дерева. Inserts an existing tree node in the tree node collection at the specified location.

Получает значение, позволяющее определить, имеет ли коллекция узлов дерева фиксированный размер. Gets a value indicating whether the tree node collection has a fixed size.

Получает или задает узел дерева по указанному индексу в коллекции. Gets or sets the tree node at the specified index in the collection.

Удаляет указанный узел дерева из коллекции узлов дерева. Removes the specified tree node from the tree node collection.

Методы расширения

Приводит элементы объекта 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.

Tree Node Collection. Item[] Свойство

Определение

Получает или задает узел дерева в коллекции. Gets or sets a tree node within the collection.

Перегрузки

Получает или задает объект TreeNode по указанному индексу в коллекции. Gets or sets the TreeNode at the specified indexed location in the collection.

Возвращает узел дерева с указанным ключом из коллекции. Gets the tree node with the specified key from the collection.

Item[Int32]

Получает или задает объект TreeNode по указанному индексу в коллекции. Gets or sets the TreeNode at the specified indexed location in the collection.

Параметры

Заданное индексом местоположение объекта TreeNode в коллекции. The indexed location of the TreeNode in the collection.

Значение свойства

Объект TreeNode, находящийся в заданном индексом местоположении в коллекции. The TreeNode at the specified indexed location in the collection.

Исключения

Значение index меньше 0 или больше последнего индекса в коллекции. The index value is less than 0 or is greater than the last index in the collection.

Читайте также:  Операционная система windows обеспечивает одинаковый пользовательский интерфейс при работе с

TreeNode, назначаемый этому индексу, уже назначен другому индексу или другому элементу управления TreeView. The TreeNode that’s being assigned to this index is already assigned to a different index or to a different TreeView control.

Примеры

Следующий пример кода удаляет первый TreeNode из, TreeView если его TreeNode.Text свойство имеет значение «узел 0». The following code example removes the first TreeNode from a TreeView if its TreeNode.Text property is set to «Node0». При Button нажатии на первый элемент TreeNode в TreeView удаляется с помощью RemoveAt метода. When a Button is clicked, the first TreeNode in the TreeView is deleted using the RemoveAt method. В этом примере необходимо создать объект и в TreeView Button Form . This example requires that you have created a TreeView and a Button on a Form. Первый TreeNode в TreeView свойстве должен иметь свойство Text «узел 0». The first TreeNode in your TreeView should have a text property of «Node0.»

Комментарии

Чтобы назначить TreeNode объекты определенному расположению или получить их из TreeNodeCollection , можно указать ссылку на объект коллекции с указанным значением индекса. To assign TreeNode objects to a specific location, or to retrieve them from the TreeNodeCollection, you can reference the collection object with a specific index value. Значение индекса объекта TreeNodeCollection является индексом, начинающимся с нуля. The index value of the TreeNodeCollection is a zero-based index.

Tree Node Collection. Insert Метод

Определение

Вставляет элемент в коллекцию по указанному индексу. Inserts an item in the collection at a specified location.

Перегрузки

Создает узел дерева с указанным ключом, текстом и изображениями и вставляет его в коллекцию по указанному индексу. Creates a tree node with the specified key, text, and images, and inserts it into the collection at the specified index.

Создает узел дерева с указанным ключом, текстом и изображениями и вставляет его в коллекцию по указанному индексу. Creates a tree node with the specified key, text, and images, and inserts it into the collection at the specified index.

Создает узел дерева с указанным ключом, текстом и изображением и вставляет его в коллекцию по указанному индексу. Creates a tree node with the specified key, text, and image, and inserts it into the collection at the specified index.

Создает узел дерева с указанным текстом и ключом и вставляет его в коллекцию. Creates a tree node with the specified text and key, and inserts it into the collection.

Вставляет существующий узел дерева в заданную позицию коллекции узлов дерева. Inserts an existing tree node into the tree node collection at the specified location.

Создает узел дерева с указанным текстом и вставляет его по указанному индексу. Creates a tree node with the specified text and inserts it at the specified index.

Создает узел дерева с указанным ключом, текстом и изображением и вставляет его в коллекцию по указанному индексу. Creates a tree node with the specified key, text, and image, and inserts it into the collection at the specified index.

Insert(Int32, String, String, String, String)

Создает узел дерева с указанным ключом, текстом и изображениями и вставляет его в коллекцию по указанному индексу. Creates a tree node with the specified key, text, and images, and inserts it into the collection at the specified index.

Параметры

Индекс в коллекции, по которому должен быть вставлен узел. The location within the collection to insert the node.

Имя узла дерева. The name of the tree node.

Текст, который должен отображаться в узле дерева. The text to display in the tree node.

Ключ изображения для отображения в узле дерева. The key of the image to display in the tree node.

Ключ изображения, которое должно быть отображено в узле дерева, когда он выбран. The key of the image to display in the tree node when it is in a selected state.

Возвращаемое значение

Объект TreeNode, вставленный в коллекцию. The TreeNode that was inserted in the collection.

Комментарии

Если Sorted свойство имеет значение true , index значение параметра игнорируется. If the Sorted property is set to true , the index parameter value is ignored. Объект TreeNode вставляется в представление в виде дерева и TreeView сортируется снова. The TreeNode is inserted into the tree view and the TreeView is sorted again.

Можно также добавлять новые TreeNode объекты в коллекцию с помощью Add AddRange методов или. You can also add new TreeNode objects to the collection by using the Add or AddRange methods.

NameСвойство соответствует ключу для TreeNode в TreeNodeCollection . The Name property corresponds to the key for a TreeNode in the TreeNodeCollection.

imageKey Параметр ссылается на изображение в ImageList свойстве родителя TreeView . The imageKey parameter refers to an image in the ImageList property of the parent TreeView.

selectedimageKey Параметр ссылается на изображение в StateImageList свойстве родителя TreeView . The selectedimageKey parameter refers to an image in the StateImageList property of the parent TreeView.

Применяется к

Insert(Int32, String, String, Int32, Int32)

Создает узел дерева с указанным ключом, текстом и изображениями и вставляет его в коллекцию по указанному индексу. Creates a tree node with the specified key, text, and images, and inserts it into the collection at the specified index.

Параметры

Индекс в коллекции, по которому должен быть вставлен узел. The location within the collection to insert the node.

Имя узла дерева. The name of the tree node.

Текст, который должен отображаться в узле дерева. The text to display in the tree node.

Значение индекса изображения для отображения в узле дерева. The index of the image to display in the tree node.

Индекс изображения, которое должно быть отображено в узле дерева, когда он выбран. The index of the image to display in the tree node when it is in a selected state.

Возвращаемое значение

Объект TreeNode, вставленный в коллекцию. The TreeNode that was inserted in the collection.

Комментарии

Если Sorted свойство имеет значение true , index значение параметра игнорируется. If the Sorted property is set to true , the index parameter value is ignored. Объект TreeNode вставляется в представление в виде дерева и TreeView сортируется снова. The TreeNode is inserted into the tree view and the TreeView is sorted again.

Читайте также:  Кнопка для загрузки диска windows

Можно также добавлять новые TreeNode объекты в коллекцию с помощью Add AddRange методов или. You can also add new TreeNode objects to the collection by using the Add or AddRange methods.

NameСвойство соответствует ключу для TreeNode в TreeNodeCollection . The Name property corresponds to the key for a TreeNode in the TreeNodeCollection.

imageIndex Параметр ссылается на изображение в ImageList свойстве родителя TreeView . The imageIndex parameter refers to an image in the ImageList property of the parent TreeView.

selectedimageIndex Параметр ссылается на изображение в StateImageList свойстве родителя TreeView . The selectedimageIndex parameter refers to an image in the StateImageList property of the parent TreeView.

Применяется к

Insert(Int32, String, String, String)

Создает узел дерева с указанным ключом, текстом и изображением и вставляет его в коллекцию по указанному индексу. Creates a tree node with the specified key, text, and image, and inserts it into the collection at the specified index.

Параметры

Индекс в коллекции, по которому должен быть вставлен узел. The location within the collection to insert the node.

Имя узла дерева. The name of the tree node.

Текст, который должен отображаться в узле дерева. The text to display in the tree node.

Ключ изображения для отображения в узле дерева. The key of the image to display in the tree node.

Возвращаемое значение

Объект TreeNode, вставленный в коллекцию. The TreeNode that was inserted in the collection.

Комментарии

Если Sorted свойство имеет значение true , index значение параметра игнорируется. If the Sorted property is set to true , the index parameter value is ignored. Объект TreeNode вставляется в представление в виде дерева и TreeView сортируется снова. The TreeNode is inserted into the tree view and the TreeView is sorted again.

Можно также добавлять новые TreeNode объекты в коллекцию с помощью Add AddRange методов или. You can also add new TreeNode objects to the collection by using the Add or AddRange methods.

NameСвойство соответствует ключу для TreeNode в TreeNodeCollection . The Name property corresponds to the key for a TreeNode in the TreeNodeCollection.

imageKey Параметр ссылается на изображение в ImageList свойстве родителя TreeView . The imageKey parameter refers to an image in the ImageList property of the parent TreeView.

Применяется к

Insert(Int32, String, String)

Создает узел дерева с указанным текстом и ключом и вставляет его в коллекцию. Creates a tree node with the specified text and key, and inserts it into the collection.

Параметры

Индекс в коллекции, по которому должен быть вставлен узел. The location within the collection to insert the node.

Имя узла дерева. The name of the tree node.

Текст, который должен отображаться в узле дерева. The text to display in the tree node.

Возвращаемое значение

Объект TreeNode, вставленный в коллекцию. The TreeNode that was inserted in the collection.

Комментарии

Если Sorted свойство имеет значение true , index значение параметра игнорируется. If the Sorted property is set to true , the index parameter value is ignored. Объект TreeNode вставляется в представление в виде дерева и TreeView сортируется снова. The TreeNode is inserted into the tree view and the TreeView is sorted again.

Можно также добавлять новые TreeNode объекты в коллекцию с помощью Add AddRange методов или. You can also add new TreeNode objects to the collection by using the Add or AddRange methods.

NameСвойство соответствует ключу для TreeNode в TreeNodeCollection . The Name property corresponds to the key for a TreeNode in the TreeNodeCollection.

Применяется к

Insert(Int32, TreeNode)

Вставляет существующий узел дерева в заданную позицию коллекции узлов дерева. Inserts an existing tree node into the tree node collection at the specified location.

Параметры

Положение в коллекции, заданное индексом, в которое вставляется узел дерева. The indexed location within the collection to insert the tree node.

Объект TreeNode для вставки в коллекцию. The TreeNode to insert into the collection.

Исключения

Значение node присвоено в текущий момент времени другому элементу управления TreeView. The node is currently assigned to another TreeView.

Примеры

В следующем примере кода выбранный узел дерева удаляется из одного TreeView и добавляется в другой, если обе коллекции узлов дерева не доступны только для чтения. The following code example removes the selected tree node from one TreeView and adds it to another if both tree node collections are not read-only. При Button нажатии на элемент, TreeNode представленный TreeView.SelectedNode свойством, удаляется из него TreeView с помощью Remove метода и добавляется в другой TreeView с помощью Insert метода. When a Button is clicked, the TreeNode represented by the TreeView.SelectedNode property is deleted from one TreeView using the Remove method and added to the other TreeView using the Insert method. В этом примере предполагается, что имеется элемент Form , содержащий два TreeView элемента управления и Button . This example requires that you have a Form that contains two TreeView controls and a Button. TreeViewЭлементы управления должны иметь имена treeView1 и treeView2 . The TreeView controls should be named treeView1 and treeView2 .

Комментарии

Если TreeView.Sorted свойство имеет значение true , index значение параметра игнорируется. If the TreeView.Sorted property is set to true , the index parameter value is ignored. Объект TreeNode вставляется в представление в виде дерева и перемещается TreeView . The TreeNode is inserted into the tree view, and the TreeView resorted.

Можно также добавлять новые TreeNode объекты в коллекцию с помощью Add AddRange методов или. You can also add new TreeNode objects to the collection by using the Add or AddRange methods.

Чтобы удалить TreeNode добавленный ранее объект, используйте Remove RemoveAt методы, или Clear . To remove a TreeNode that you previously added, use the Remove, RemoveAt, or Clear methods.

TreeNodeМожет быть назначен только одному TreeView элементу управления за раз. A TreeNode can be assigned to only one TreeView control at a time. Чтобы добавить узел дерева в новый элемент управления представлением в виде дерева, необходимо сначала удалить его из другого представления дерева или клонировать. To add the tree node to a new tree view control, you must remove it from the other tree view first or clone it.

Оцените статью