Neven Draskovic

Neven Draskovic

  • NA
  • 117
  • 139.9k

Using progress bar

Jul 3 2012 5:10 AM
Hey

I made an application that passes trough an XML file and "extracts" the entries that have a specific value of a certain attribute. The application works fine, but the XML file has over 52,000 entries and only 3 values to sort by (so naturally it takes some time to execute it). Because of that I want to implement a progress bar so I can follow the progress my application made. I googled it, but none of the solutions work for me (the application does it's work, but the progress bar doesn't move at all), so if you could help me that would be grate.

The code that extracts the entries is this:
XmlNodeList nodes;
string ExtractedXML = "";

 private void extractingXMLToolStripMenuItem_Click(object sender, EventArgs e)
{
  if (nodes.Count != 0)
{
  foreach (XmlNode node in nodes)
{
 if (String.Compare(node.ChildNodes[6].ChildNodes[0].Attributes.GetNamedItem("code").Value.ToString(), "CodeValue") == 0)
{
tempXML = node.InnerXml;
temp = "<" + node.Name + " code=\"" + node.Attributes.GetNamedItem("code").Value + "\">" + Environment.NewLine;
temp += tempXML + Environment.NewLine;
temp += "</" + node.Name + ">";
ExtractedXML += temp + Environment.NewLine;
temp = "";
}
}
  textBox1.Text = ExtractedXML;
}
}

There is a ToolStripMenue item for each value with similar code, only the "CodeValue" changes. How can I implement the progress bar to show me how far did the application get?
Thanks