BlakeMcKenna
asked on
Changing a single DataGridView rows' backcolor???
Is it possible to change a single row's backcolor? I'm using a DataGridView and I edit the rows. For each row that has been edited...I wish to signify that by changing it's row color.
Thanks,
Blake
Thanks,
Blake
also you can use the cell formatting event
private void dataGrid_CellFormatting(ob ject sender, DataGridViewCellFormatting EventArgs e)
{
int rowIndex = e.RowIndex;
DataGridViewRow theRow = dataGrid.Rows[rowIndex];
double cellValue = (double)theRow.Cells[”Quan tity”].Val ue;
if (cellValue =1)
{
theRow.DefaultCellStyle.Ba ckColor = Color.Red;
}
else
{
// theRow.DefaultCellStyle.Ba ckColor = Color.Blue;
}
}
private void dataGrid_CellFormatting(ob
{
int rowIndex = e.RowIndex;
DataGridViewRow theRow = dataGrid.Rows[rowIndex];
double cellValue = (double)theRow.Cells[”Quan
if (cellValue =1)
{
theRow.DefaultCellStyle.Ba
}
else
{
// theRow.DefaultCellStyle.Ba
}
}
ASKER
Problem with this is....if you click on another row...Rows(1) loses the color. Only the CurrentRow will change colors. I want to click on a row and set the backcolor and have it stay that color....click on another row and have it stay that color too.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
db.Rows(1).DefaultCellStyl