You can try tracking selected rows yourself and toggle the selections
on and off in the CellClick event. You can use the RowPrePaint event
to set the backcolor of selected rows.
//in form.load
this.dataGridView1.DefaultCellStyle.SelectionBackColor =
Color.FromArgb(0, Color.Black); //hide normal color
this.dataGridView1.EditMode =
DataGridViewEditMode.EditProgrammatically;
this.dataGridView1.CurrentCell = null;
this.dataGridView1.CellClick += new
DataGridViewCellEventHandler(dataGridView1_CellClick);
this.dataGridView1.RowPrePaint += new
DataGridViewRowPrePaintEventHandler(dataGridView1_RowPrePaint);
private List<int> selectedRowIndexes = new List<int>();
void dataGridView1_RowPrePaint(object sender,
DataGridViewRowPrePaintEventArgs e)
{
if (this.selectedRowIndexes.IndexOf(e.RowIndex) > -1)
dataGridView1.Rows[e.RowIndex].DefaultCellStyle.BackColor =
Color.LightBlue;
else
dataGridView1.Rows[e.RowIndex].DefaultCellStyle.BackColor =
SystemColors.Window;
}
void dataGridView1_CellClick(object sender,
DataGridViewCellEventArgs e)
{
if (this.selectedRowIndexes.IndexOf(e.RowIndex) > -1)
this.selectedRowIndexes.Remove(e.RowIndex);
else
this.selectedRowIndexes.Add(e.RowIndex);
this.dataGridView1.CurrentCell = null;
}
==================
Clay Burch
Syncfusion, Inc.