本文整理汇总了C#中Controls.SuspendLayout方法的典型用法代码示例。如果您正苦于以下问题:C# Controls.SuspendLayout方法的具体用法?C# Controls.SuspendLayout怎么用?C# Controls.SuspendLayout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Controls
的用法示例。
在下文中一共展示了Controls.SuspendLayout方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateActorEditingControls
public static void CreateActorEditingControls(HeaderCommands.Actors.Entry ac, Controls.TableLayoutPanelEx tlpex, Action numberchanged, object tag = null, bool individual = false)
{
//TODO TODO TODO: more value types, more control types, etc, etc!!!
/* No proper actor entry given? */
if (ac == null || ac.Definition == null)
{
tlpex.Controls.Clear();
return;
}
/* Get current definition */
Definition def = ac.Definition;
/* No definition given? */
if (def == null) return;
/* Begin layout creation */
tlpex.SuspendLayout();
tlpex.Controls.Clear();
/* Create description label */
Label desc = new Label()
{
Text = (ac.InternalName == string.Empty ? ac.Name : string.Format("{0} ({1})", ac.Name, ac.InternalName)),
TextAlign = ContentAlignment.MiddleLeft,
Dock = DockStyle.Fill
};
tlpex.Controls.Add(desc, 0, 0);
tlpex.SetColumnSpan(desc, 2);
/* Parse items */
for (int i = 0; i < def.Items.Count; i++)
{
/* Get current item */
Definition.Item item = def.Items[i];
/* UGLY HACK -> for room number in transition actor with individual file mode... */
if (item.Usage == Definition.Item.Usages.NextRoomBack || item.Usage == Definition.Item.Usages.NextRoomFront)
item.ControlType = (individual ? typeof(TextBox) : typeof(ComboBox));
/* Get value, create control */
object val = GetValueFromActor(item, ac);
object ctrl = Activator.CreateInstance(item.ControlType);
/* First ControlType check; ex. is label needed? */
if (item.ControlType == typeof(CheckBox))
{
/* Add control alone */
tlpex.Controls.Add(ctrl as Control, 0, (i + 1));
}
else
{
/* Add label and control */
Label lbl = new Label() { Text = string.Format("{0}:", item.Description), TextAlign = ContentAlignment.MiddleLeft, Dock = DockStyle.Fill };
tlpex.Controls.Add(lbl, 0, (i + 1));
tlpex.Controls.Add(ctrl as Control, 1, (i + 1));
}
/* Set control properties */
item.ControlType.GetProperty("Dock").SetValue(ctrl, DockStyle.Fill, null);
item.ControlType.GetProperty("Tag").SetValue(ctrl, item, null);
item.ControlType.GetProperty("Name").SetValue(ctrl, item.Usage.ToString(), null);
/* ControlType-specific settings */
if (item.ControlType == typeof(ComboBox))
{
/* Set ComboBox */
item.ControlType.GetProperty("DropDownStyle").SetValue(ctrl, ComboBoxStyle.DropDownList, null);
item.ControlType.GetProperty("DisplayMember").SetValue(ctrl, "Description", null);
if (!individual && (item.Usage == Definition.Item.Usages.NextRoomBack || item.Usage == Definition.Item.Usages.NextRoomFront) && (tag is List<HeaderCommands.Rooms.RoomInfoClass>))
{
/* Item usage is room number in transition actor; get room listing from function tag */
item.Options = new List<Definition.Item.Option>();
foreach (HeaderCommands.Rooms.RoomInfoClass ric in (tag as List<HeaderCommands.Rooms.RoomInfoClass>))
item.Options.Add(new Definition.Item.Option() { Description = ric.Description, Value = ric.Number });
}
if (item.Options.Count > 0)
{
item.ControlType.GetProperty("DataSource").SetValue(ctrl, item.Options, null);
item.ControlType.GetProperty("SelectedItem").SetValue(ctrl, item.Options.Find(x => x.Value == (Convert.ToUInt64(val) & item.Mask)), null);
(ctrl as ComboBox).SelectedIndexChanged += new EventHandler((s, ex) =>
{
SetValueInActor(item, ac, ((Definition.Item.Option)((ComboBox)s).SelectedItem).Value);
});
}
}
else if (item.ControlType == typeof(CheckBox))
{
/* Set CheckBox */
item.ControlType.GetProperty("Checked").SetValue(ctrl, Convert.ToBoolean(val), null);
item.ControlType.GetProperty("Text").SetValue(ctrl, item.Description, null);
tlpex.SetColumnSpan(ctrl as Control, 2);
(ctrl as CheckBox).CheckedChanged += new EventHandler((s, ex) =>
{
ChangeBitInActor(item, ac, item.Mask, ((CheckBox)s).Checked);
});
}
//.........这里部分代码省略.........