C# Winforms - 控件的滚动条何时初始化?

发布于 2024-10-30 13:14:49 字数 1217 浏览 1 评论 0原文

情况如下:

我试图从 devexpress 控件 VerticalScroll 控制 flowLayoutControl 的滚动条。

现在 - flowLayoutControl 与 autoscroll = true。我添加了一个新的垂直滚动控件并将其停靠在右侧。现在,Devexpress Vertical Scroll 控件位于 FlowLayout 滚动条的正上方。

另外,运行以下代码时,FlowLayoutPanel 垂直滚动不会隐藏:

    spotWinFlowLayout1.VerticalScroll.Visible = false

我已经设置了以下事件处理程序:

    private void spotWinFlowLayout1_Resize(object sender, EventArgs e)
    {
        SetupVerticalScrollBar();
    }        

    private void SetupVerticalScrollBar()
    {
        vScrollBar1.Minimum = spotWinFlowLayout1.VerticalScroll.Minimum;
        vScrollBar1.Maximum = spotWinFlowLayout1.VerticalScroll.Maximum;
        vScrollBar1.LargeChange = spotWinFlowLayout1.VerticalScroll.LargeChange;
        vScrollBar1.SmallChange = spotWinFlowLayout1.VerticalScroll.SmallChange;            
    }

    private void vScrollBar1_Scroll(object sender, ScrollEventArgs e)
    {
        spotWinFlowLayout1.VerticalScroll.Value = e.NewValue;
    }

一切正常,除了在表单 Load 上时,flowLayoutControl 上已经有一个滚动条, spotWinFlowLayout1.VerticalScroll.XXX 属性尚未设置。所以两个滚动条都不同步。但一旦我调整表单大小,两者就会同步。

那么 FlowLayoutPanel 的滚动条何时初始化?

Here is the situation:

I am trying to control flowLayoutControl's scroll bar from devexpress controls VerticalScroll.

Now - flowLayoutControl with autoscroll = true. I added a new verticalscroll control and dock it to Right. So now the Devexpress Vertical Scroll control is right on top of FlowLayout scrollbar.

Also the FlowLayoutPanel vertical scroll does not hide when following code is run:

    spotWinFlowLayout1.VerticalScroll.Visible = false

I have setup the following event handlers:

    private void spotWinFlowLayout1_Resize(object sender, EventArgs e)
    {
        SetupVerticalScrollBar();
    }        

    private void SetupVerticalScrollBar()
    {
        vScrollBar1.Minimum = spotWinFlowLayout1.VerticalScroll.Minimum;
        vScrollBar1.Maximum = spotWinFlowLayout1.VerticalScroll.Maximum;
        vScrollBar1.LargeChange = spotWinFlowLayout1.VerticalScroll.LargeChange;
        vScrollBar1.SmallChange = spotWinFlowLayout1.VerticalScroll.SmallChange;            
    }

    private void vScrollBar1_Scroll(object sender, ScrollEventArgs e)
    {
        spotWinFlowLayout1.VerticalScroll.Value = e.NewValue;
    }

Everything is working fine except when on form Load there is already a scrollbar on flowLayoutControl,
spotWinFlowLayout1.VerticalScroll.XXX properties not set yet. So both the scrollbars are out of Sync. But as soon as I resize the form both get Sync.

So when is scrollbar for the FlowLayoutPanel initialized?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

各自安好 2024-11-06 13:14:49

那么什么时候滚动条
FlowLayoutPanel 已初始化?

这可能听起来像 smartalec 的答案:“当控件被绘制或放置在表单上时”,这就是当您调整表单大小时它们同步的原因。(它们再次被绘制)

解决办法是自己手动添加滚动条。

So when is scrollbar for the
FlowLayoutPanel initialized?

This might sound like a smartalec answer: "When the control is drawn or placed on the form" which is the reason when you adjust the size of the form they are in sync.( they are being drawn again )

The solution is to manually add the scrollbars yourself.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文