DataGridView non-focused selection appearance

P

Paul E

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!
 
G

Geoff Munday

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
 
P

Paul E

Geoff said:
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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top