473,569 Members | 2,747 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help on Adding tree node ??

Dear all,

I have an application which timely create log file in XML format
I ma using the SystemFileWatch er object to monitor creation of new file in
the proper path. So far no problem

When the first file is created, my SystemFile onchanged event is catch and
then I add the new log file in a treview control with the following code:

Dim m_Root As New TreeNode
m_Root = Me.tLogView.Nod es.Item(0)
'For idx = 0 To sFile.Count - 1
Dim m_Node As New TreeNode(e.Name , 2, 2)
m_Root.Nodes.Ad d(m_Node)
m_Root.Nodes.Ad d(m_Node)

When the second file is created, event is cacthed again, and I am suppose to
add the new file to the treeview as previous step. But at that time I have an
exception which says something like I am not in the current thread and I need
to call Control.Invoke before adding my new node ???

What sors it means ? how can add new nodes when Onchange event occurs?

thaks for your help
regards
serge
Jul 21 '05 #1
1 1344
The Control class requires methods to be invoked on the thread in which the Control was created. The event that is being handled
(your "OnChanged" event) is running on a thread-pooled thread.

Do something like this (sorry that my VB isn't very good):

Private Delegate AddNodeInvoker( Name as String)

Public Sub OnChanged(sende r as Object, e As EventArgs)
If Me.tLogView.Inv okeRequired Then
Dim _AddNode As New AddNodeInvoker( AddNode)
Dim Params As New Object(1)
Params(0) = e.Name
Me.tLogView.Inv oke(_AddNode, Params)
Else
AddNode(e.Name)
End If
End Sub

Private Sub AddNode(Name as String)
Dim m_Root As New TreeNode
m_Root = Me.tLogView.Nod es.Item(0)
'For idx = 0 To sFile.Count - 1
Dim m_Node As New TreeNode(Name, 2, 2)
m_Root.Nodes.Ad d(m_Node)
m_Root.Nodes.Ad d(m_Node)
End Sub

--
Dave Sexton
dave@www..jwaon line..com
-----------------------------------------------------------------------
"serge calderara" <se************ @discussions.mi crosoft.com> wrote in message
news:A6******** *************** ***********@mic rosoft.com...
Dear all,

I have an application which timely create log file in XML format
I ma using the SystemFileWatch er object to monitor creation of new file in
the proper path. So far no problem

When the first file is created, my SystemFile onchanged event is catch and
then I add the new log file in a treview control with the following code:

Dim m_Root As New TreeNode
m_Root = Me.tLogView.Nod es.Item(0)
'For idx = 0 To sFile.Count - 1
Dim m_Node As New TreeNode(e.Name , 2, 2)
m_Root.Nodes.Ad d(m_Node)
m_Root.Nodes.Ad d(m_Node)

When the second file is created, event is cacthed again, and I am suppose to
add the new file to the treeview as previous step. But at that time I have an
exception which says something like I am not in the current thread and I need
to call Control.Invoke before adding my new node ???

What sors it means ? how can add new nodes when Onchange event occurs?

thaks for your help
regards
serge

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2162
by: Tree menu using XML | last post by:
I have one XML file that has nodes and sub node and each and every node has the attribute call visible if its value is true then diplay this node else don't display thid node, but this condition i am able to check using xpath in asp.net 2.0 till MenuItem node. if i check visible attribute value till SubMenuLevel0 node then in tree it will not...
4
9005
by: Tarique Jawed | last post by:
Alright I needed some help regarding a removal of a binary search tree. Yes its for a class, and yes I have tried working on it on my own, so no patronizing please. I have most of the code working, even the removal, I just don't know how to keep track of the parent, so that I can set its child to the child of the node to be removed. IE - if...
2
1626
by: New | last post by:
Why does this code insert a node into a binary search tree correctly? If I only inserting going by first digit it works properly but when I try inserting going by the whole ip and the port number the inserts are totally out of order. where IPAddress is four ints Node is an IPAddress, portNumber, left pointer and right pointer Nodeptr is a...
3
2462
by: Brian Henry | last post by:
If i already have a tree view created, and want to add another new node to it, how would i do so? Is there a way to throught tags or anything? like i have this RootNode | +-- Child 1 +-- Child 2 and i want to add a child node to child 1 how would i refrence it and add a
3
1097
by: you | last post by:
Ok, I hope that I can 'splain this right. I am very new so bear with me. I have a treeview with its main node being a user selected folder. In this treeview you can only see subfolders and two specific file types. What I am trying to do next is to remove any subfolders from the tree that bo not have any of the two file types. This is done to...
2
2174
by: andrew browning | last post by:
gbd says the segmentation fault is being generated in the insert function. //CONSTRUCTOR tree():data(value_type()), left(0), right(0){}; tree(value_type vt, tree* l = 0, tree* r = 0): data(vt), left(l), right(r) {}; //PRIVATE MEMBERS
66
5315
by: genestarwing | last post by:
QUESTION: Write a program that opens and read a text file and records how many times each word occurs in the file. Use a binary search tree modified to store both a word and the number of times it occurs. After the program has read the file, it should offer a menu with three choices. the first is to list all the words along with the number of...
5
5265
gekko3558
by: gekko3558 | last post by:
I am writing a simple binary search tree (nodes are int nodes) with a BSTNode class and a BST class. I have followed the instructions from my C++ book, and now I am trying to get a remove method working. But before I get to the remove, I need to get my find method working. Basically, I am trying to get a "find" method working that will search for...
3
1500
by: shotokan99 | last post by:
hi guys, my question is regarding yui tree menu. im a newbie and trying to take advantage of this rich library. my worry is about removeNode() or how to remove or delete a node on real-time. i have a code that contains a button and when the user push this button it will create a node on real-time. and my code goes like this: ...
1
1231
by: happy.john1234 | last post by:
Hi, i am a new bie in programming.I am currently doing a project that displays certain hierarchial set of data in tree view.I currently implemented this tree view to be displayed in xml file which is one of my requirement too.But, the point that i am confused is with further processing.I have to move accross tree node to recover various...
0
8118
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7666
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6278
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5504
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2107
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
936
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.