How to scroll in flowlayout panel without showing scrollbar in windows form

前端 未结 2 835
灰色年华
灰色年华 2021-01-19 07:26

I am working on a touch screen POS in WinForms.

I have a flowlayoutpanel and add buttons dynamically but I dont want to show a scrollbar.

I use 2 buttons to

2条回答
  •  [愿得一人]
    2021-01-19 07:56

    Take two buttons btnLeft and btnRight and try this code :

    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);
            }
        }
    }
    

提交回复
热议问题