Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 scroll instead, so please help me how to scroll without showing a scrollbar

like image 633
kapil Avatar asked Jan 17 '23 10:01

kapil


2 Answers

Try placing the FlowLayoutPanel inside another panel with these properties:

flowLayoutPanel1.AutoScroll = false;
flowLayoutPanel1.AutoSize = true;
flowLayoutPanel1.AutoSizeMode = AutoSizeMode.GrowAndShrink;

From here, you have to control yourself the location of the FlowLayoutPanel1 inside your panel (which should also have AutoScroll = false;) based on your two buttons.

like image 62
LarsTech Avatar answered Jan 31 '23 01:01

LarsTech


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);
        }
    }
}
like image 27
kakarott Avatar answered Jan 31 '23 02:01

kakarott