Link to home
Start Free TrialLog in
Avatar of BlakeMcKenna
BlakeMcKennaFlag for United States of America

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
Avatar of JonMny
JonMny



db.Rows(1).DefaultCellStyle.BackColor
also you can use the cell formatting event


private void dataGrid_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{

int rowIndex = e.RowIndex;
DataGridViewRow theRow = dataGrid.Rows[rowIndex];

double cellValue = (double)theRow.Cells[”Quantity”].Value;
if (cellValue =1)
{
theRow.DefaultCellStyle.BackColor = Color.Red;
}
else
{
// theRow.DefaultCellStyle.BackColor = Color.Blue;
}
}
Avatar of BlakeMcKenna

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
Avatar of JonMny
JonMny

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial