FlowLayoutPanel AutoSize only in vertical?

2019-06-17 04:46发布

I'm loading images dynamically inside a FlowLayoutPanel. I need for this panel to auto-size but only vertically.

Is this possible, and if so, how do I go about achieving it?

2条回答
唯我独甜
2楼-- · 2019-06-17 05:11

Simple, add a event of type control added:

private void flowLayoutPanel1_ControlAdded(object sender, ControlEventArgs e)
{
    if (flowLayoutPanel1.Controls.Count % 10 == 0)
        flowLayoutPanel1.SetFlowBreak(e.Control as Control, true);
}

set AutoSize = true

set flowdirection = LeftToRight

查看更多
Rolldiameter
3楼-- · 2019-06-17 05:11

I did set the Size from panel dinamically. Example:

int newHeight= listImages.Count/10 * 100;
               flowLayoutPanel1.Size = new Size(1143, newHeight);

It works for me. Thx all

查看更多
登录 后发表回答