Hi,
Apologies if this is a daft question, I usually get involved with web stuff.
We have a MatchLevelID Column in our RadGridView.
The MatchLevelID can either be 0, 1, 2 or 3
What we would like to do is set the background colour of the Cell depending on the MatchLevelID.
To do this, we are subscribing to the CellFormatting Event.
Here is the code we have so far :
private void rgv_CellFormatting(object sender, CellFormattingEventArgs e)
{
if (e.CellElement.ColumnInfo.Name == "MatchLevelID")
{
var cellInfo = e.CellElement.RowInfo.Cells[e.CellElement.ColumnIndex];
var matchLevelID = (int) cellInfo.Value;
switch (matchLevelID)
{
case 0:
e.CellElement.BackColor = Color.Red;
break;
case 1:
e.CellElement.BackColor = Color.Orange;
break;
case 2:
e.CellElement.BackColor = Color.Yellow;
break;
case 3:
e.CellElement.BackColor = Color.Green;
break;
}
}
}
What is happening is that the background colour is only being set in the MatchLevelID Cell for the Row that the Cursor is hovering over.
As soon as we move the Cursor to another Row the background colour for the new Row is changed and the colour for the old Row is lost.
Ideally we would like the colour to be set for all the Cells in the MatchLevelID Column when the Grid loads.
Any ideas ?
Apologies if this is a daft question, I usually get involved with web stuff.
We have a MatchLevelID Column in our RadGridView.
The MatchLevelID can either be 0, 1, 2 or 3
What we would like to do is set the background colour of the Cell depending on the MatchLevelID.
To do this, we are subscribing to the CellFormatting Event.
Here is the code we have so far :
private void rgv_CellFormatting(object sender, CellFormattingEventArgs e)
{
if (e.CellElement.ColumnInfo.Name == "MatchLevelID")
{
var cellInfo = e.CellElement.RowInfo.Cells[e.CellElement.ColumnIndex];
var matchLevelID = (int) cellInfo.Value;
switch (matchLevelID)
{
case 0:
e.CellElement.BackColor = Color.Red;
break;
case 1:
e.CellElement.BackColor = Color.Orange;
break;
case 2:
e.CellElement.BackColor = Color.Yellow;
break;
case 3:
e.CellElement.BackColor = Color.Green;
break;
}
}
}
What is happening is that the background colour is only being set in the MatchLevelID Cell for the Row that the Cursor is hovering over.
As soon as we move the Cursor to another Row the background colour for the new Row is changed and the colour for the old Row is lost.
Ideally we would like the colour to be set for all the Cells in the MatchLevelID Column when the Grid loads.
Any ideas ?