Reputation: 8226
When add some controls to a FlowLayoutPanel
, Is there any way to find which controls cause to the flow break in a new line?
for(i=0;i!=100;i++){
var userControl = new MyUserControl();
myFlowLayoutPanel.Controls.Add(userControl);
}
These 100 userControls
arranged in 20 rows and 5 columns, so the 1st, 5th, 15th, .., 100th user control cause the myFlowLayoutPanel
breaks in new lines.
I a'm looking for a way to detect these controls.
Upvotes: 1
Views: 927
Reputation: 4202
Unfortunately, there is no method or property which would provide you this information, but you could calculate it manually:
Control prevControl = null;
foreach (Control control in myFlowLayoutPanel.Controls)
{
if (prevControl == null || prevControl.Left > control.Left)
{
// line break
}
prevControl = control;
}
Upvotes: 2