This is the print.config file

<PrintingConfiguration>
  <Printers>
    <Printer DisplayName="text1">senthil</Printer>
    <Printer DisplayName="text1">kumar</Printer>
  </Printers>
</PrintingConfiguration>
Step 1 : Create a click event and then load the xml file in XMLDocument object.
Step 2 : Select the corresponding node using "SelectSingleNode".
Step 3 : Next i will pass the delete node value "delectvalue" from the "MyDataGrid" grid view row DisplayName "Text1".
Step 4 : Delete the Selected node.
private void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            var doc = new XmlDocument();
            doc.Load(AppDomain.CurrentDomain.BaseDirectory + "..\\..\\Printing.config");           

            XmlNode root = doc.SelectSingleNode("//Printers");
            Author customerRow = MyDataGrid.SelectedItem as Author;

            string delectvalue = customerRow.DisplayName;

            string xpath = "//Printer[@DisplayName= \"" + delectvalue + "\"]";
            XmlNode currentNode = root.SelectSingleNode(xpath);
            
            if (currentNode != null)
            {
                // Delete the record.
                root.RemoveChild(currentNode);
            }
            // Save the changes. 
            doc.Save(printconfigFolder);

            LoadCustomers();
            MyDataGrid.Items.Refresh();
        }

0 comments

Related Posts Plugin for WordPress, Blogger...