本文整理汇总了C#中System.Windows.Forms.Layout.LayoutEngine.Layout方法的典型用法代码示例。如果您正苦于以下问题:C# LayoutEngine.Layout方法的具体用法?C# LayoutEngine.Layout怎么用?C# LayoutEngine.Layout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.Layout.LayoutEngine
的用法示例。
在下文中一共展示了LayoutEngine.Layout方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Layout
public override bool Layout(
object container,
LayoutEventArgs layoutEventArgs)
{
Control parent = container as Control;
// Use DisplayRectangle so that parent.Padding is honored.
Rectangle parentDisplayRectangle = parent.DisplayRectangle;
Point nextControlLocation = parentDisplayRectangle.Location;
foreach (Control c in parent.Controls)
{
// Only apply layout to visible controls.
if (!c.Visible)
{
continue;
}
// Respect the margin of the control:
// shift over the left and the top.
nextControlLocation.Offset(c.Margin.Left, c.Margin.Top);
// Set the location of the control.
c.Location = nextControlLocation;
// Set the autosized controls to their
// autosized heights.
if (c.AutoSize)
{
c.Size = c.GetPreferredSize(parentDisplayRectangle.Size);
}
// Move X back to the display rectangle origin.
nextControlLocation.X = parentDisplayRectangle.X;
// Increment Y by the height of the control
// and the bottom margin.
nextControlLocation.Y += c.Height + c.Margin.Bottom;
}
// Optional: Return whether or not the container's
// parent should perform layout as a result of this
// layout. Some layout engines return the value of
// the container's AutoSize property.
return false;
}