Controls - Do you make the selected/enabled rows stand out in a datagrid?
  v2.0 Posted at 24/02/2017 1:35 AM by Tiago Araujo

Many times you allow a multiple selection in a grid by using a checkbox. When you do this make it easy to see the distinction of a row that is selected and one that is not. Make it subtle by dimming the unselected text.

Seleted rows not standard out
Figure: Bad Example - Selected rows are not separate from others.
Seleted rows standard out
Figure: Good Example - Selected rows are separate from others.
To make this effect in datagrid, you may need to edit the cellcontentclick event handler code.

private void DatagridviewRules_CellContentClick(object sender, DataGridViewCellEventArgs e)
if (DatagridviewRules.Columns[e.ColumnIndex] is DataGridViewCheckBoxColumn && e.ColumnIndex == 0 &&
e.RowIndex != -1)
bool boolCheckBox = (bool)(DatagridviewRules.Rows[e.RowIndex].Cells[e.ColumnIndex].Value);
DatagridviewRules.Rows[e.RowIndex].DefaultCellStyle.ForeColor = boolCheckBox
? SystemColors.WindowText
: SystemColors.ControlDark;
DataRowView objDataRowView = (DataRowView)DatagridviewRules.Rows[e.RowIndex].DataBoundItem;
JobRule.DataTableJobRulesRow objDataRow = (JobRule.DataTableJobRulesRow)(objDataRowView.Row);
updateRuleIsEnabled(objDataRow.RuleId, boolCheckBox);

Setting the ForeColor to different ones, like black and gray, can separate the selected rows from others.

Related rules

    Do you feel this rule needs an update?

    If you want to be notified when this rule is updated, please enter your email address: