使用AutoScroll抑制FlowLayoutPanel中的自动滚动 [英] suppressing automatic scrolling within FlowLayoutPanel with AutoScroll

查看:254
本文介绍了使用AutoScroll抑制FlowLayoutPanel中的自动滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个FlowLayoutPanel,AutoScroll设置为true。它有一个TopDown流,在我将称为"标题"的自定义控件和每个标题下面的DataGridView之间交替。在任何给定的FlowLayoutPanel中可以有任意数量的这些控制对。由于单个DataGridViews变长,或者当FlowLayoutPanel中的控件数量对于屏幕来说太长时,会自动出现垂直滚动条,如预期的那样。

问题我所拥有的是在DataGridView中进行行选择可能导致DataGridView突然滚动到FlowLayoutPanel的可滚动窗口的顶部或底部。如果DGV在顶部不是完全可见的,它会向下滚动直到它。同样,如果DGV在底部不是完全可见的,它会向上滚动直到它为止。虽然我希望这是在自动滚动容器中选择控件的预期结果,但这对我的用户来说相当令人不安。他们可以很好地看到他们想要选择的行,并且不关心他们是否在同一个DGV中看不到所有其他行。我想抑制这个功能,但无法弄清楚如何。

The problem that I am having is that making a row selection within a DataGridView can cause that DataGridView to abruptly scroll to the top or bottom of the scrollable window of the FlowLayoutPanel.  If the DGV isn’t entirely visible towards the top, it scrolls downwards until it is.  Likewise, if the DGV isn’t entirely visible on the bottom, it scrolls upwards until it is.  Although I expect this is an intended consequence of selecting a control within an auto-scrolling container, this is rather disconcerting to my users.  They can see the rows they want to select quite well, and don’t care if they don’t see all the others within the same DGV.  I would like to suppress this functionality, but can’t figure out how. 

我真的希望有一个可取消的事件,我可以编写一个处理程序并将e.Cancel设置为true。我找不到这样的事件。我也找不到任何可以组合起来的ScrollableControl属性来给我这个效果。我们非常感谢您提出的任何建议。

推荐答案

应该注意的是"报头QUOT; FlowLayoutPanel中的控件与问题无关。我构建了一个非常简单,可重现的对话框,其中包含一个包含三个DataGridView的AutoScroll FlowLayoutPanel,它们总共大于包含的对话框。只需在DGV中选择一个在对话框中不完全可见的行,它将完全滚动到视图中。

It should be noted that the inclusion of "header" controls into the FlowLayoutPanel has nothing to do with the issue.  I built a very simple, reproducable case of a dialog with an AutoScroll FlowLayoutPanel containing three DataGridViews, which in total are larger than the containing dialog.  Just select a row in a DGV which isn't entirely visible in the dialog, and it will scroll entirely into view.

顺便说一句,我很乐意附上一个这样的zip文件这个帖子的情况,但我无法弄清楚如何添加附件。那好吧。我可以通过电子邮件发送给任何好奇的人。

As an aside, I'd happily attach a zip file of this case to this posting, but I can't figure out how to add an attachment.  Oh well.  I can email it to anyone who is curious.

与此同时,我已经使用自己的滚动编码而不是使用AutoScroll。但这不是一种幸福的状态。如果我能解决这个问题,我更愿意恢复AutoScroll!

In the meantime, I have resorted to coding up my own scrolling rather than using AutoScroll.  But this isn't a happy state of affairs.  I would much prefer to reinstate AutoScroll if I could just figure out this issue!


这篇关于使用AutoScroll抑制FlowLayoutPanel中的自动滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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