是否可以避免对 SplitContainer 的关注?
WinForm SplitContainer 在拖动或单击时获得焦点,而 Splitter 则不会。 这样做的副作用是,拖动 SplitContainer 栏会触发其他控件上的 Leave/Validate,我需要避免这种情况。
我已经尝试将 TabStop 和 CausesValidation 设置为 False,但没有成功。
有没有办法阻止 SplitContainer 获得焦点? (没什么大不了的,我仍然可以使用旧的 Splitter,但我失去了一些不错的 VS 属性......)
The WinForm SplitContainer gets the focus when it's dragged or clicked, while the Splitter does not.
The side-effect of this, is that dragging a SplitContainer bar fires Leave/Validate on other controls, and I need to avoid this.
I already tried setting TabStop and CausesValidation to False, but with no success.
Is there a way to stop the SplitContainer from getting focused? (not a big deal, I can still use the old Splitter, but I lose some nice VS properties...)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Filini,
拆分容器唯一获得焦点的时间是当您实际移动拆分器时。 所以我会在你的验证和离开事件中做类似的事情。
我重现了您的问题,当我添加上面的内容时,它当然仍然调用该事件,但是代码执行不会发生,因为在您移动拆分器时 SplitContainer 具有焦点。
希望有帮助。
Filini,
The only time that the splitcontainer would have focus is when you are actually moving the splitter. So I would so something like this in your validating and leave events.
I reproduced your issue and when I added the above it still calls the event of course, but the code execution doesn't occur because the SplitContainer has focus while you are moving the splitter.
Hope that helps.
尝试使用以下代码:
Try with this code:
删除 SplitContainer 控件并手动将其替换为 Panel 和 Splitter 控件。 多一点努力,但结果会干净得多。
Remove the SplitContainer control and replace it manually with Panel and Splitter controls. A little more effort, but a much cleaner outcome.