FlowBreak & FlowLayoutPanel

E

Ethan Strauss

Hi,
I have a Winform with a FlowLayoutPanel on it. I will be adding controls
to that panel at runtime and I don't know the number that will added ahead of
time. I would like the user to be able to see all the controls added when the
form is at it's MinimumSize (which is what it starts at). In order to do
that, the controls will generally have to be layed out in several columns
with 3-4 controls per column. I was hoping that the FlowLayoutPanel would do
that automatically, but it does not.
It seems like I should use the FlowLayoutPanel.SetFlowBreak() method to
get the Panel to start a new column, but I can find almost no info on what
this method does and how to use it. The documentation just tells me it "Sets
the value that represents the flow-break setting of the FlowLayoutPanel
control." Not too helpful.
Anyway, I have tried SetFlowBreak to true, but that does nothing I can
see. The method takes a Control parameter, which I have set to the last
control added or the next one to be added, but that does not seem to matter.
Does anyone know if SetFlowBreak is really what I want? If not, what
should I be using? What does the control parameter in SetFlowBreak do?

I would appreciate any help.
Thanks
Ethan


Ethan Strauss Ph.D.
Bioinformatics Scientist
Promega Corporation
2800 Woods Hollow Rd.
Madison, WI 53711
608-274-4330
800-356-9526
(e-mail address removed)
 
E

Ethan Strauss

Thanks Peter,
I was not getting FlowBreaks because I had WrapContents set to false
(trhe default) and didn't think to fiddle with it.
Ethan


Peter Duniho said:
[...] In order to do
that, the controls will generally have to be layed out in several columns
with 3-4 controls per column. I was hoping that the FlowLayoutPanel
would do
that automatically, but it does not.
It seems like I should use the FlowLayoutPanel.SetFlowBreak() method
to
get the Panel to start a new column, but I can find almost no info on
what
this method does and how to use it.

IMHO, it can be inferred from the overview doc
(http://msdn.microsoft.com/en-us/library/f9e8s203.aspx) and the method
documentation. But I agree, the docs could be more specific. You should
consider sending feedback to Microsoft when you run into things like this.
[...]
Anyway, I have tried SetFlowBreak to true, but that does nothing I can
see. The method takes a Control parameter, which I have set to the last
control added or the next one to be added, but that does not seem to
matter.
Does anyone know if SetFlowBreak is really what I want? If not, what
should I be using? What does the control parameter in SetFlowBreak do?

It tells the panel to break the flow at the given child control. You
_could_ use this to achieve your goal, assuming you've done the work to
figure out on which child control you need to break.

But, it seems based on your description, that what you really want is just
to set the FlowLayoutPanel.WrapContents property to true, and then make
sure that the panel itself sizes according to the parent window (anchored,
dock as "fill", whatever). Then the panel will automatically flow the
children so that they stay within the width of the control (assuming they
flow across, then down).

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top