如何在c#中为流布局面板创建自定义滚动按钮#

我必须为流布局面板项目创建向上和向下按钮垂直滚动。我该怎么办?我会为POS做这个表格。如何在c#中为流布局面板创建自定义滚动按钮#

我这样做,但它不工作:我有很多按钮,他们有87尺寸高度:我添加了代码和图片。

private void btnScrollUp_Click(object sender, EventArgs e) 

{

flowLayoutPanel1.VerticalScroll.Value = flowLayoutPanel1.VerticalScroll.LargeChange-1 ;

flowLayoutPanel1.PerformLayout();

}

private void btnScrollDown_Click(object sender, EventArgs e)

{

flowLayoutPanel1.VerticalScroll.Value = flowLayoutPanel1.VerticalScroll.LargeChange+ 1;

flowLayoutPanel1.PerformLayout();

}

回答:

或者你可能只是想设置“自动滚动”假下面的代码实现适当的编程滚动:

public Form1() 

{

InitializeComponent();

flowLayoutPanel1.AutoScroll = false;

}

public int scrollValue = 0;

public int ScrollValue

{

get

{

return scrollValue;

}

set

{

scrollValue = value;

if (scrollValue < flowLayoutPanel1.VerticalScroll.Minimum)

{

scrollValue = flowLayoutPanel1.VerticalScroll.Minimum;

}

if (scrollValue > flowLayoutPanel1.VerticalScroll.Maximum)

{

scrollValue = flowLayoutPanel1.VerticalScroll.Maximum;

}

flowLayoutPanel1.VerticalScroll.Value = scrollValue;

flowLayoutPanel1.PerformLayout();

}

}

private void Add_Control(object sender, EventArgs e)

{

flowLayoutPanel1.Controls.Add(new Button(){Width = flowLayoutPanel1.Width, Height = 87});

}

private void UpClick(object sender, EventArgs e)

{

ScrollValue -= flowLayoutPanel1.VerticalScroll.LargeChange;

}

private void DownClick(object sender, EventArgs e)

{

ScrollValue += flowLayoutPanel1.VerticalScroll.LargeChange;

}

回答:

什么类型的滚动的,你想实现的,将这段代码是吗?

How to Programmatically Scroll a Panel

这可以让你每个控制滚动,而不是一个“平稳”的滚动,但我认为这会为你的应用程序。

以上是 如何在c#中为流布局面板创建自定义滚动按钮# 的全部内容, 来源链接: utcz.com/qa/262832.html

回到顶部