D
Debra has a question
Guest
I have a datagridview which the user can check off and every row that gets checked of that rows back color changes to yellow. When the user sorts the datagridview then any row that was yellow loses its background color and reverts back to the original back color. How can I change that so the user can sort with out losing its yellow back color.
Also, Im trying to handle that when the user tries checking off the checkbox column and the criteria for checking off were not met a message box should pop up and say that the box cant be checked off. Below is the code to do this.
private void dgv_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
{
if(e.ColumnIndex == 0 && e.RowIndex > -1 && (bool)dgv.Rows[0].FormattedVaue == false)
{
if(criteria......)
{
e.cancel = true
MessageBox.Show("Cant check off row.");
}
}
}
The problem is that the header columns all have the column and row index of 0 so when I try sorting the columns if the first check box cant be checked off this message box will pop up. Is there anything that can be done about this problem?
Debra has a question
Continue reading...
Also, Im trying to handle that when the user tries checking off the checkbox column and the criteria for checking off were not met a message box should pop up and say that the box cant be checked off. Below is the code to do this.
private void dgv_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
{
if(e.ColumnIndex == 0 && e.RowIndex > -1 && (bool)dgv.Rows[0].FormattedVaue == false)
{
if(criteria......)
{
e.cancel = true
MessageBox.Show("Cant check off row.");
}
}
}
The problem is that the header columns all have the column and row index of 0 so when I try sorting the columns if the first check box cant be checked off this message box will pop up. Is there anything that can be done about this problem?
Debra has a question
Continue reading...