0

Here is what i am doing right now.

private void gvOrderList_RowStyle(object sender, RowStyleEventArgs e)
{
        GridView View = sender as GridView;
        if (e.RowHandle >= 0)
        {
            string sGridRecordOrderNumber = View.GetRowCellDisplayText(e.RowHandle, View.Columns["orderNo"]);
            foreach (string sNewRecordOrderNo in oNewRecordOrderNoList)
            {
                if (sGridRecordOrderNumber == sNewRecordOrderNo)
                {
                    e.Appearance.BackColor = Color.Salmon;
                    e.Appearance.BackColor2 = Color.SeaShell;
                    break;
                }
            }
        }
    }

I fire sql queries every 30 seconds using thread and give datasource as a list. oNewRecordOrderNoList contains my new record list. I am matching it's OrderNo column with the handle's same column to get highlighted rows.

I am getting my rows highlighted as expected but also getting A BIG CROSS over my gridcontrol for 1 second. And if i open other forms after the current one, it also shows cross in other forms. LOOKS QUITE UGLY.

I want a solution to remove this cross or another solution by which i can change appearance of my new rows by matching column values WITHOUT A CROSS DISPLAY.

A help would be appreciated.

Brij Parekh
  • 11
  • 1
  • 4

1 Answers1

0

Red cross means that an exception occurred while painting the grid. Since you're changing the datasource, it would be a good idea to deffer highlighting until the data is loaded. Something like this:

private void LoadData() {
  myGridView.BeginDataUpdate();
  myGridControl.DataSource = GetNewDataSource();
  myGridView.EndDataUpdate();
}
Marko Juvančič
  • 5,792
  • 1
  • 25
  • 41
  • sorry but i tried this. It didnt work. Cross is still there. I dont understand why this cross appears in other forms. If i comment the data of row_style event, the cross disappears. – Brij Parekh Jan 28 '15 at 09:47
  • Comment the code in gvOrderList_RowStyle. Is the cross still there? – Marko Juvančič Jan 29 '15 at 08:06
  • No. As i told before, cross disappears as i comment the code in the event. Everything is working properly if i comment the code of the event. So there is something wrong in the code of this event only. By the way, thanks for giving time for the query. – Brij Parekh Jan 30 '15 at 13:43