The selection settings is taken from the system setting (Advanced
Appearance tab of the Display settings om the Control Panel). One way
you can override this default behavior is to handle the CellPainting
event.
void dataGridView1_CellPainting(object sender,
DataGridViewCellPaintingEventArgs e)
{
if (e.RowIndex > -1 && e.ColumnIndex > -1)
{
e.Paint(e.ClipBounds, DataGridViewPaintParts.Background
| DataGridViewPaintParts.Border
| DataGridViewPaintParts.ContentBackground
| DataGridViewPaintParts.ContentForeground);
if
(this.dataGridView1.SelectedCells.Contains(this.dataGridView1[e.ColumnIndex,
e.RowIndex]))
{
using (Brush b = new SolidBrush(Color.FromArgb(60,
Color.Red)))
{
e.Graphics.FillRectangle(b, e.CellBounds);
}
}
e.Handled = true;
}
}
==================
Clay Burch
Syncfusion, Inc.
Simon Harvey - 12 Feb 2007 19:42 GMT
Woah - holly cow - I was kinda hoping there was just a property that I
could use to set tyle stuff!
Or maybe using some "row selected" or "on selection" changed style event.
All that painting stuff seems hard! Is there something simpler?
Many thanks for your help
Simon
Simon Harvey schreef:
> Hi
>
[quoted text clipped - 4 lines]
> Am I missing something here? Do I have to write some custom formatting
> code?
There are DefaultCellStyle.SelectionForeColor and ..SelectionBackColor

Signature
Tim Van Wassenhove <url:http://www.timvw.be/>
Simon Harvey - 13 Feb 2007 15:25 GMT