Hi all,
I have a DataGridView that displays an XML file in it... the table has
these column names: Name, Value, Data. After I've populated it I need
to compare (via a method call) the data in the Name cell with the
string value in the XML comment. So basically I'm comparing the Name
cells value with the comment value in the XML file.
The XML file contains the useual <name>, <value> & <comment> tags.
How would I do that? Also I want to color the cells Name & Value if
they do not match?
private void SeeForMatch()
{
XmlDocument doc = GetXmlDocument(); // loads XML file
DataTable dt = datagridView1.DataSource as DataTable;
foreach (DataRow rows in dt.Rows) // loops through the
datagridview1 or should I use:
// foreach
(DataGridViewRow rows in dt.Rows) 'cos I need the cell coloring
{
string name = (string)rows["name"];
foreach (XmlNode node in doc.SelectNodes("//data")) // loops
through the XML file
{
if (node.Attributes["comment"].Value.Equals(name)) // !!!
// should be if ( the string value in the cell not equal to
the <comment> value in the xml file)
// { color both cells & check the rest of the name column
with the XML <comments> }
I know if I wanted to color the cells I would use:
rows["name"].Style.BackColor = System.Drawing.Color.Blue; //assuming
rows was a DataGridView but it's DataRow type!!
Thanks for your help ppl.