Flowlayoutpanel control flow

Zexor

Well-known member
Joined
Nov 28, 2008
Messages
520
Programming Experience
3-5
I have a flowlayoutpanel, and a few picturebox in it. i size the window so each picturebox take a line. if i make the window bigger, 2 box will take a line. But if i make the window smaller again, it still 2 box in one line instead of shrinking back down. i want it just to scroll vertically and not horizontally. the panel is anchor to all 4 sizes.
 
Last edited:
The whole point of the FlowLayoutPanel is the flow. If you don't want it to flow then it's pointless. Use a TableLayoutPanel with one column instead.

Also, as Dunfiddlin suggests, why would you have the panel anchored to all four sides if you don't want it to change it's Width? If you don't want the panel to get wider then why Anchor it to both sides?
 
i want it to flow, just dont want it to scroll sideway. flow lefttoright was the one i use, it make the scroll go vertical. Its like once it spring out wide, it doesnt spring back.
 
Last edited:
Ah, I see what you're saying now then. I've actually never used a FlowLayoutPanel before but I just tested and it worked fine for me. I created a form, added a FLP and resized it so it snapped to all four edges and Anchored it to all four edges. I then added a PictureBox and set its BorderStyle to FixedSingle. I copied that PictureBox seven times, so the FLP contained eight PictureBoxes. I then resized the form so that the FLP was the correct dimensions to just contain all the PictureBoxes in a single column. Finally, I changed the AutoScroll property of the FLP to True. When I ran the project, the PictureBoxes reflowed correctly as I resized the form. They overflowed downwards by default and I only ever saw a horizontal scroll bar when the form was too narrow to display a single PictureBox.

Have you maybe changed the FlowDirection to TopDown? From what you describe, it should be LeftToRight, which is the default.
 
Yes I have it lefttoright, wrapcontent true so that when the form is around the pic box size it only show one vertical column with vertical scroll. And when I maximize, it show 2 columns. But when I return the form to normal, it is still 2 columns with vertical and horizontal scroll bars. I have also have a panel above the picture box. And I have it resize to a little smaller than the float when the flow resize so that the pic box won't go up to it. Apparently that is the problem. I removed the changing size and it works fine. But then the pic box will go up to the panel if I maximize.
 
Last edited:
for some reason, this is what causing the problem it seem. I checked, the Control width is correct and the flow width is correct after the resize, the pic boxes some how are outside the correct size of the flow area. So it need a scroll bar. I have a text box inside the panel. I added the panel so that it can resize and take up the whole width and the picbox wont move up. But then it created a different problem.

VB.NET:
    Private Sub FlowLayoutPanel1_SizeChanged(sender As Object, e As EventArgs) Handles FlowLayoutPanel1.SizeChanged
        For Each Control As Control In FlowLayoutPanel1.Controls
            If TypeOf (Control) Is Panel Then
                Control.Width = FlowLayoutPanel1.Width - 31
            End If
        Next
    End Sub

How do i keep the picBox from going up to the textbox line while the picbox will still spring back to a single column?
 
Last edited:
This is the first we're hearing about these Panels and this:
the pic box will go up to the panel if I maximize
conveys nothing useful. It's (past) time for a FULL and CLEAR explanation of the problem.
 
Ok this is what I have in the flow panel at the beginning.
A text box 150 width
A bunch of picture box width 600, I also have a group box around each pic box.
Then text box 150 again and picture 600 and repeat
So if I have the window width a little over 600, I will not see the horizontal scroll of the flow panel. With a single column of controls vertically.

If I maximize the window, the first row will be the text box and a couple picture box. This is what I was trying to prevent by adding the panel around the text box and changing its width. I want the text box all by itself in that row with its 150 width. Same goes for all the other textboxes.

But it seems like if I change the width of the panel during the flow change size, it will mess up something with the flow and it won't spring back.
 
I have to say, I find I very hard to see how you could think that all that stuff about the TextBox and the Panel weren't relevant. This casts a completely different light on matters. Please provide a full description up front in future because it's a waste of everyone's time otherwise. You said that you had FlowLayoutPanel with a few PictureBoxes in it. Surely you can see that that is simply not the case. I'll have a closer look at all the facts when I have the chance.
 
Ok, i changed the setting and set the flow panel to Top Down and no wrap. So now it will always only have a single column. But if i change any of the control size in the flowpanel sizechange event. The horizontal scroll bar will come back, even if there are no control when it scroll to the right. its just a big empty space. I keep the control width to slightly less than the flowpanel width.
 
Back
Top