Am I being dumb? I read a XML file into a DataGridView...
The XML file contents show in the grid OK.Code:Dim oDSet = New System.Data.DataSet oDSet.ReadXml(strFilePath) DataGridView1.DataSource = oDSet.Tables(0)
I iterate through the rows, and if there's bad data in the row I set the colour to red, and add a value to what would end up as a hidden new column, with the intention of sorting later to show all the error rows together.
It sort of works, although I've found that I can't sort easily on a non-data-bound new column.Code:DataGridView1.Columns.Add("test1", "Errors") For Each drow As System.Windows.Forms.DataGridViewRow In DataGridView1.Rows If drow.Cells("Whatever").Value.ToString = "Wrong" Then DataGridView1.Rows(drow.Index).DefaultCellStyle.BackColor = Color.Red DataGridView1.Rows(drow.Index).Cells("test1").Value = "ERR" End If Next
My question is, though, if I click on a column heading to sort, all my red changes - and new values in the new test1/"Errors" column - all vanish!
Why is that, and how do I actually achieve this?
Thanks






Reply With Quote