Hi Hevin
I think you might have added the nodes one by one to the TreeView.
Is it true?
Yes, this is true!
So that I can edit the selected node and the corresponding sub-nodes in the
UserControl, I declare the XmlDocument in the MainForm as static public.
public static XmlDocument dom;
In the AfterSelect event, I pass the selected XmlNode to the UserControl:
if (e.Node.Tag is System.Xml.XmlNode)
{
XmlNode xmlNode = (XmlNode)e.Node.Tag;
if (xmlNode.Name == "Account")
{
if (xmlNode.HasChildNodes)
{
//userControl1.SelectedXmlNode = xmlNode;
userControl1.SetXmlNode(xmlNode);
}
}
}
That solutions works now for me.
But I have now an other question. My Xml looks as follows.
<?xml version="1.0" encoding="utf-8"?>
<EasyCrypto.NET name="Root">
<Category name="e-Banking">
<Account name="Bank1">
<Username>Gaga</Username>
<Password>test@Bank1</Password>
<URL>http://www.bank1.com</URL>
<Description>Bank1 e-Banking Account</Description>
</Account>
</Category>
<Category name="Web">
<Account name="hotmail">
<Username>user_hotmail_06</Username>
<Password>test</Password>
<URL>http://www.hotmail.com</URL>
<Description>Hotmail</Description>
</Account>
<Account name="gmail">
<Username>user:gmail</Username>
<Password>test_gmail</Password>
<URL>http://www.gmail.com</URL>
<Description>Gmail</Description>
</Account>
</Category>
</EasyCrypto.NET>
How can I "move" now a XmlNode Account, for example gmail, to an other
category (node Category)?
Thanks and Regards,
andersch
"Kevin Yu [MSFT]" wrote:
Hi Andersch,
To achieve this, it depends on how you apply the XmlDocument to the
TreeView. Since the Windows form tree view doesn't support binding to a
data source, I think you might have added the nodes one by one to the
TreeView. Is it true?
If so, I think you have to specify the identity for each node. You can
define an XPath to search for specific node in the TreeView and in
XmlDocument. When a node is selected in the TreeView, go through its
ancestors to get each node. Then you can use this path to find in your
XmlDocument. When it is modified, change it also in the TreeView. As far as
I can see, this is the only way. I hope any community member can shed some
light on this if they have any better ways.
Kevin Yu
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
(This posting is provided "AS IS", with no warranties, and confers no
rights.)