Setting Autoscroll to true causes focus to lose focus in .net datagrid
I have a huge datagrid control embedded in a window and the Autoscroll property is true. In addition, the control also has text boxes. This grid is intended for monitors with a resolution higher than 1600 (and therefore the scrollbar is not visible at this resolution). But the Autoscroll property is tuned to force the user to use it on small monitors as well.
It works like clicking a cell, for example, the cursor is positioned in a text box that is located in the far right corner of the grid and therefore does not appear on small monitors. But due to the functionality described above, whenever I click on a cell, the grid loses focus and the scrollbar moves to the right side of the grid.
I don't want the scrollbar to move in order to focus on text boxes. Help is needed. Thanks.
a source to share
"Just in case someone stumbles upon this post looking for a way to disable the AutoScroll scrolling behavior for a focused control, the cleanest solution is provided in .NET 2.0: ScrollableControl now has an overridden ScrollToControl method. Call base class implementation to return DisplayRectangle.Location and problem solved "
- Gem in the comment section of this great blog post: http://seewinapp.blogspot.com/2005/09/is-your-autoscroll-too-auto.html
The blog post and comment answered the need
a source to share