当前位置: 首页>>代码示例>>C#>>正文


C# Controls.SetColumnSpan方法代码示例

本文整理汇总了C#中Controls.SetColumnSpan方法的典型用法代码示例。如果您正苦于以下问题:C# Controls.SetColumnSpan方法的具体用法?C# Controls.SetColumnSpan怎么用?C# Controls.SetColumnSpan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Controls的用法示例。


在下文中一共展示了Controls.SetColumnSpan方法的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);
                    });
                }
//.........这里部分代码省略.........
开发者ID:kskjer,项目名称:SceneNavi,代码行数:101,代码来源:XMLActorDefinitionReader.cs


注:本文中的Controls.SetColumnSpan方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。