private void dgvItemsDetails_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (dgvItemsDetails.Columns[selected.Name].Index == e.ColumnIndex)
{
dgvItemsDetails.MultiSelect = true;
if (Convert.ToBoolean(dgvItemsDetails[selected.Name, e.RowIndex].FormattedValue) == true)
{
dgvItemsDetails[selected.Name, e.RowIndex].Value = false;
}
else
{
dgvItemsDetails[selected.Name, e.RowIndex].Value = true;
}
}
int i = 0;
foreach (DataGridViewRow dgvrow in dgvItemsDetails.Rows)
{
if (Convert.ToBoolean(dgvrow.Cells[0].Value.ToString()) == true)
{
SetDataGridViewRowAsHighlighted(dgvItemsDetails, i, true);
}
else
{
SetDataGridViewRowAsHighlighted(dgvItemsDetails, i, false);
}
i++;
}
}
private void SetDataGridViewRowAsHighlighted(DataGridView dgvItemsDetails,int intRowIndex, bool boolIsChecked)
{
if (boolIsChecked == true)
{
dgvItemsDetails.Rows[intRowIndex].Selected = true;
dgvItemsDetails.Rows[intRowIndex].DefaultCellStyle.SelectionBackColor = Color.LightSlateGray;
}
else
{
dgvItemsDetails.Rows[intRowIndex].Selected = false;
dgvItemsDetails.Rows[intRowIndex].DefaultCellStyle.SelectionBackColor = Color.White;
}
}
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment
It is the same account you read, post and publish with — and you will come straight back to this page.
Former memberPosted Jun 29, 2009, 1:09 AM
Hello Shweta , Very first congrats for your 1st article. I would like to congrats you , that you taken a very often topic to discuss. that is nice. your code is working good also.. I do have some constructive feedback. 1. Give little of explanation of article also 2. Try to paste code from your visual studio as it is. Such that , in your article it will have the same color as of code window color. 3. Give Objective of article Thank you so much and looking forward for more articles form you.