如何使用按钮点击事件滚动flowlayoutpanel(向上和向下) [英] Howto scroll flowlayoutpanel with button click event (up & down)

查看:116
本文介绍了如何使用按钮点击事件滚动flowlayoutpanel(向上和向下)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的人们



我正在尝试使用点击事件按钮在运行时滚动我的FlowLayoutPanel UP或DOWN但由于某种原因它无法正常工作。这是代码。



Dear people

I'm trying to scroll my FlowLayoutPanel UP or DOWN using click event button at run time but for some reason its not working. Here is the code.

private void cmdButtonsUp_Click(object sender, EventArgs e)
        {
            int curItem = this.flowLayoutStockInButtonsPanel.VerticalScroll.Value;
            if (curItem > 0)
            {
                this.flowLayoutStockInButtonsPanel.VerticalScroll.Value = this.flowLayoutStockInButtonsPanel.VerticalScroll.LargeChange - 1;
            }
        }
        private void cmdButtonsDown_Click(object sender, EventArgs e)
        {
            int curItem = this.flowLayoutStockInButtonsPanel.VerticalScroll.Value;
            if (curItem < 0)
            {
                this.flowLayoutStockInButtonsPanel.VerticalScroll.Value = this.flowLayoutStockInButtonsPanel.VerticalScroll.LargeChange + 1;
            }
        }





有人可以帮助我,也许我错过了我的代码......



提前致谢





Lapeci



Could someone please help me maybe I'm missing something on my code...

Thanks in advance


Lapeci

推荐答案

您的控件如何知道修改了 VerticalScroll 属性?

您需要触发布局更新。



当滚动位置改变时,添加:



How your control knows that VerticalScroll properties are modified?
You need to trigger the layout update.

When the scrolling position is changed, add:

flowLayoutStockInButtonsPanel.PerformLayout();





彻底检查逻辑,计算和约束。特别是,使用 VerticalScroll.Minimum (你使用0,这是不正确的), VerticalScroll.Maximum VerticalScroll.SmallChange



Thoroughly check up logics, calculation and constraints. In particular, use VerticalScroll.Minimum (you’re using 0, this is incorrect), VerticalScroll.Maximum, VerticalScroll.SmallChange.


在这两种情况下,curItem都是< = And> =
In both cases curItem would be <= And >=


这篇关于如何使用按钮点击事件滚动flowlayoutpanel(向上和向下)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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