我已经试过了,但效果不太好
- 对于按钮11-15,只有
"<"
出现,因为一旦点击,就没有其他按钮了。 - 按钮6-10显示,
<
和›
均可见 - 查看按钮1-5:只有一个
›
按钮
例如,如果有15个按钮,屏幕只能显示5个按钮"<"
和"»"
按钮出现,当点击时,向左或向右滚动它应该跳转视图。例如,按一次它应该显示按钮6-10,然后再次按它显示按钮11-15需要2次点击才能看到整个15个按钮
partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
// need to disable AutoScroll, otherwise disabling the horizontal scrollbar doesn't work
Panel.AutoScroll = false;
// disable horizontal scrollbar
Panel.HorizontalScroll.Enabled = false;
}
public int scrollValue = 0;
public int ScrollValue
{
get
{
return scrollValue;
}
set
{
scrollValue = value;
if (scrollValue < Panel.HorizontalScroll.Minimum)
{
scrollValue = Panel.HorizontalScroll.Minimum;
}
if (scrollValue > Panel.HorizontalScroll.Maximum)
{
scrollValue = Panel.HorizontalScroll.Maximum;
}
Panel.HorizontalScroll.Value = scrollValue;
Panel.PerformLayout();
}
}
private void btnleft_Click(object sender, EventArgs e)
{
ScrollValue -= Panel.HorizontalScroll.LargeChange;
}
private void btnright_Click(object sender, EventArgs e)
{
ScrollValue += Panel.HorizontalScroll.LargeChange;
}
private void button1_Click(object sender, EventArgs e)
{
Panel.Controls.Add(new Button()
{
Width = 67,
Height = Panel.Height
});
}
}
1条答案
按热度按时间oxalkeyp1#
你必须有2个按钮左右
我为这样图像编写代码,代码如下:
当我们按下这些按钮时