I have two DataGridViews on a form. (I'm using .NET 2005)

When I run it, I can't tell which control has the focus because the
selection looks the same on both controls.

I'd like the selection appearance to work the way Windows Explorer does
where only one control has the regular blue selection, and the other
controls have a gray selection when they are not selected.

How do I do that?

Thanks!

Re: DataGridView non-focused selection appearance by Geoff

Geoff
Thu Jun 08 12:19:37 CDT 2006

Hi Paul,

Try having both DataGridViews use the same method to handle their
GotFocus event and determine which DGV (see "sender") got focus and
which lost focus and update each's
"myDataGridView.DefaultCellStyle.SelectionBackColor" property
accordingly.

Regards,

Geoff
http://nonspect.com



Paul E wrote:
> I have two DataGridViews on a form. (I'm using .NET 2005)
>
> When I run it, I can't tell which control has the focus because the
> selection looks the same on both controls.
>
> I'd like the selection appearance to work the way Windows Explorer does
> where only one control has the regular blue selection, and the other
> controls have a gray selection when they are not selected.
>
> How do I do that?
>
> Thanks!


Re: DataGridView non-focused selection appearance by Paul

Paul
Thu Jun 08 14:06:43 CDT 2006

Geoff Munday wrote:
> Hi Paul,
>
> Try having both DataGridViews use the same method to handle their
> GotFocus event and determine which DGV (see "sender") got focus and
> which lost focus and update each's
> "myDataGridView.DefaultCellStyle.SelectionBackColor" property
> accordingly.

Well, that is similar to what I was thinking, but it just seems funny
that I would have to do that by hand. It seems like it should just work
like that by default. Would anyone want to have two DataGridViews
visible at the same time and have both of them appear focused at the
same time, even though only one really was?

In my case it is a little more complicated because selecting something
on one grid changes the rows on the other, so I have to call the
other's SelectionBackColor whenever someone changes the selection, too,
as well as when I initially create the grids.

Thanks!