Vote count:
0
private void btnAddNodes_Click(object sender, EventArgs e) { string inputt = Microsoft.VisualBasic.Interaction.InputBox("Enter Node Name", "Create Node", "", -1, -1); txtAdd.Text = inputt; if (treeView1.SelectedNode != null) { if(txtAdd.Text.Length!=0)
{ //TreeNode childNode = new TreeNode(txtAdd.Text);
//treeView1.SelectedNode.Nodes.Add(childNode); //treeView1.ExpandAll(); Binding(txtAdd.Text); } else { MessageBox.Show("Please Enter Value"); } } else { MessageBox.Show("Please Select Parent Node"); }
private XmlNode GetXmlNode(TreeNode tnode, XmlDocument d)
{
//XDocument xdoc = XDocument.Load(path);
// XmlDocument xmlDoc = new XmlDocument();
XmlNode n = d.CreateNode(XmlNodeType.Element, txtAdd.Text, "");
foreach (TreeNode t in tnode.Nodes)
{
n.AppendChild(GetXmlNode(t, d));
}
return n;
}
private void btnAddAttributes_Click(object sender, EventArgs e)
{
string input = Microsoft.VisualBasic.Interaction.InputBox("Enter Attribute Name", "Create Node", "", -1, -1);
txtAddd.Text = input;
// TreeCall();
TreeNode select_node1 = new TreeNode();
TreeNode select_node = treeView1.SelectedNode;
string selectedfullpath = select_node.FullPath;
txtAdd.Text = selectedfullpath;
if (input == "")
{
MessageBox.Show("Text Box Cannot be Empty");
return;
}
else
{
string output = selectedfullpath.Replace(@"\", @"/");
//saveFile();
//xmldoc.Load(txtfilepath.Text);
XmlNode node = xmldoc.SelectSingleNode(output);
XmlAttribute attributes = xmldoc.CreateAttribute(input);
attributes.Value = input;
node.Attributes.Append(attributes);
MessageBox.Show("d");
xmldoc.Save(txtfilepath.Text);
}
}
asked 32 secs ago
how add Nodes And Attributes in C# winforms .(Treeevieew)
Aucun commentaire:
Enregistrer un commentaire