Hi there,
is there a way to draw the Focus Rectangle around active Row also when the Grid is not focused?
Thanks a lot for any help!
Hi,
Typically, you would not use a focus rectangle for something like that, since it would be confusing. If the application did not have focus and it showed a focus rectangle, it might be difficult for the user to tell which application has focus. So, for example, when the user pressed a key on the keyboard, they won't know where it's going to go.
This is probably not a big deal, since the form header displays as active on only one form, but as a Windows standard, an inactive application does not show a focus rectangle.
As an alternative, you could use the ActiveRowAppearance property on the grid.DisplayLayout.Override to highlight the active row in the grid using BackColor/ForeColor. The row remains active regardless of the focus.
if you have 2 displays for example, and you switch from my application on the left one into an other application on the right one, you cant see which row was (is) activated in my application. so you have to activate my application before you can see the active row.
The focus rectangle is intended to display which control on a form has focus. So if you draw the focus rectangle when the control does not have focus, then there could potentially be 2 focus rectangles displayed at the same time. That seems like a very odd UI choice and probably violates some Windows standards and it could be pretty confusing to your users. Why would you want to do this?
To answer your question, yes, I'm pretty sure it's possible to achieve this, but you would have to use a DrawFilter to draw the focus rect yourself. I don't think this would be too difficult. You would have to determine what UIElement currently draws the focus rect and then trap for when the grid does not have focus and then draw it. You would also have to try to determine how the grid calculates the rect in which to draw the focus rectangle, but that should be possible with a little bit of trial-and-error.