如何防止容器自动滚动当部分可见的子控件获得焦点? [英] How to prevent container to autoscroll when a partially-visible child control got focus?

查看:156
本文介绍了如何防止容器自动滚动当部分可见的子控件获得焦点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

具有启用滚动条的面板有许多按钮。如果我按下列表键,焦点在按钮之间导航。



当部分可视按钮有焦点时,面板会自动滚动以完全显示按钮。 >

有没有办法阻止滚动?

解决方案

创建自己的Panel控件并覆盖 ScrollToControl 方法:

 公共类PanelEx 
继承Panel

受保护的覆盖函数ScrollToControl(activeControl As Control)As
返回Me.AutoScrollPosition
End Function

End Class


A panel with enabled scrollbars has many buttons. If I push the tabulation key, focus navigates between buttons.

When a partially visible button has focus, the panel scrolls itself in order to completely show the button.

Is there a way to prevent that scrolling?

解决方案

You would have to create your own Panel control and override the ScrollToControl method:

Public Class PanelEx
  Inherits Panel

  Protected Overrides Function ScrollToControl(activeControl As Control) As Point
    Return Me.AutoScrollPosition
  End Function

End Class

这篇关于如何防止容器自动滚动当部分可见的子控件获得焦点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆