I have a grid which is utilizing a creation filter which added a checkbox to the header of the grid. When this checkbox is checked/unchecked, the checkboxelement click event is fired and handled in the creation filter, which raises an event that is handled by another object(my grid class implementing the creation filter).
My problem is when I have scrollable screen and the user clicks a header checkbox, the screen jumps the grid control to the top of the screen and the event does not fire.
However, once the grid is at the top of the screen, the user can click the header checkbox without the screen jumping the control to the top(since it is already there), and it works fine.
How do I get the click event to fire for the header checkbox that was clicked? I guess I need the click event for the creation filter to fire before the screen gets jumped, how do I do that. Or, how do I avoid the jumping of the screen?
Thanks for your help,
Dave Krecker
Hi,
Sorry about that. I was sure there was a way to turn off the automatic scrolling of controls into view, but I can't seem to find it now.
It looks like the only way to work around something like this is to use a new property that was added to Control in CLR2 called AutoScrollOffset. I think what you would have to do is set this in the MouseDown of the grid so that it scrolls the grid to where it already is. This is pretty complicated, though, because it depends on whether or not the upper-left corner of the grid is already in view or not.
The AutoScroll property on the panel enables scroll bars to appear is the control withing the panel is larger than the panel itself. If I disable the autoScroll property, I lose my toolbars. Even if I set the visible and enable properties of the horizontal and vertical scrollbars in code to true, they show up but do not function if the autoScroll is set to false.
Hi Dave,
When you use a scrollable control, there's a property on it called (I think) AutoScroll. This property automatically scrolls the top-left corner of a control into view whenever that control gets focus.
So my guess is that when you click on the grid, the grid gets focus on or shortly after the MouseDown event occurs. Then the scrollable control scrolls so that the top-left of the grid is in view. And by the time the MouseUp occurs, the checkbox is no longer under the mouse, so the checkbox doesn't get changed.
So the easiest thing to do would be to turn off AutoScroll.