我正在WinForms上开发一个触摸屏POS系统。
我使用流式布局面板(flowlayoutpanel)并动态添加按钮,但我不想显示滚动条。
我使用了两个按钮来进行滚动,因此请帮助我如何在不显示滚动条的情况下进行滚动。
我正在WinForms上开发一个触摸屏POS系统。
我使用流式布局面板(flowlayoutpanel)并动态添加按钮,但我不想显示滚动条。
我使用了两个按钮来进行滚动,因此请帮助我如何在不显示滚动条的情况下进行滚动。
尝试将FlowLayoutPanel放置在具有以下属性的另一个面板中:
flowLayoutPanel1.AutoScroll = false;
flowLayoutPanel1.AutoSize = true;
flowLayoutPanel1.AutoSizeMode = AutoSizeMode.GrowAndShrink;
从这里开始,你需要控制 FlowLayoutPanel1 在面板内的位置(该面板应该也具有 AutoScroll=false;
),以便根据你的两个按钮进行操作。
private void btnLeft_Click(object sender, EventArgs e)
{
if (flowPanelItemCategory.Location.X <= xpos)
{
xmin = flowPanelItemCategory.HorizontalScroll.Minimum;
if (flowPanelItemCategory.Location.X >= xmin)
{
xpos -= 100;
flowPanelItemCategory.Location = new Point(xpos, 0);
}
}
}
private void btnRight_Click(object sender, EventArgs e)
{
if (flowPanelItemCategory.Location.X <= xpos)
{
xmax = flowPanelItemCategory.HorizontalScroll.Maximum;
if (flowPanelItemCategory.Location.X < xmax)
{
xpos += 100;
flowPanelItemCategory.Location = new Point(xpos, 0);
}
}
}