-
Привет
А есть ли в сабже у нодов область для хранения произвольных данных (аналог Node.Data в делфях) и как к ней подобраться.
Зы изучаю всего неделю %) Троелсен как-то не удосужился хотя бы бегло пробежаться по компонентам.
-
> А есть ли в сабже у нодов область для хранения произвольных
> данных (аналог Node.Data в делфях)
TreeNode.Tag
-
позор троелсену и всей его клике
-
> _Ламер_ (13.10.06 12:33)
> Зы изучаю всего неделю %) Троелсен как-то не удосужился
> хотя бы бегло пробежаться по компонентам.
Я думаю, что при такой документации ему было бы достаточно вместо всей книги написать: "Читайте MSDN!!!".
Кстати, действительно нелепо искать в учебниках справочную информацию.
Хотя... Не издать ли мне MSDN? :)))
-
> Игорь Шевченко © (13.10.06 15:17) [1]
> > А есть ли в сабже у нодов область для хранения произвольных
>> > данных (аналог Node.Data в делфях)
> TreeNode.Tag
А нафига, собственно? Если можно наделать сколько угодно колонок (сделать их невидимыми, если надо) и хранить в них сколько угодно произвольных данных?
-
Ну в MSDN по запросу TreeView ничего про tag не нашёл. А нашёл только по ключевому слову tag. Но я, по-моему, не просил давать ответа по поводу поиска соответствующей литературы, а вопрос задал прямо.
Не прощаюсь %)
-
Курдль © (13.10.06 18:16) [4]
> А нафига, собственно?
"Property Value
An Object that contains data about the tree node. The default is a null reference (Nothing in Visual Basic).
Remarks
Any Object derived type can be assigned to this property. If this property is being set through the Windows Forms designer, only text can be assigned.
Example
The following code example creates a root tree node to assign child tree nodes to. A child tree node for each Customer object in an ArrayList is added to the root tree node as well as a child tree node for each Order object assigned to the Customer object. The Customer object is assigned to the Tag property, and the tree nodes representing Customer objects are displayed with Orange text. This example requires that you have a Customer and Order object defined, a TreeView control on a Form, and an ArrayList named customerArray containing Customer objects."
public void AddRootNodes()
{
// Add a root node to assign the customer nodes to.
TreeNode rootNode = new TreeNode();
rootNode.Text = "CustomerList";
// Add a main root treenode.
myTreeView.Nodes.Add(rootNode);
// Add a root treenode for each 'Customer' object in the ArrayList.
foreach(Customer myCustomer in customerArray)
{
// Add a child treenode for each Order object.
int i = 0;
TreeNode[] myTreeNodeArray = new TreeNode[5];
foreach(Order myOrder in myCustomer.CustomerOrders)
{
myTreeNodeArray[i] = new TreeNode(myOrder.OrderID);
i++;
}
TreeNode customerNode = new TreeNode(myCustomer.CustomerName,
myTreeNodeArray);
// Display the customer names with and Orange font.
customerNode.ForeColor = Color.Orange;
// Store the Customer object in the Tag property of the TreeNode.
customerNode.Tag = myCustomer;
myTreeView.Nodes[0].Nodes.Add(customerNode);
}
}
Каждый сам в меру своей испорченности выберет способ ассоциации прикладных данных с узлом TreeView.
-
А какое событие возникает при удалении узла?
-
> [7] _Ламер_ (07.11.06 20:03)
> А какое событие возникает при удалении узла?
MSDN -> TreeView class, events
все события, как на ладони
-
Удалено модератором
-
Удалено модератором