Esempio n. 1
0
        public static void LoadListColumns(List <string> data, System.Windows.Forms.ListView.ColumnHeaderCollection ll)
        {
            ll.Clear();

            foreach (var item in data)
            {
                var t = new System.Windows.Forms.ColumnHeader();
                t.Text = item;
                ll.Add(t);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 返回指定列名的索引位置
        /// </summary>
        public static int IndexOfHeader(System.Windows.Forms.ListView.ColumnHeaderCollection chc, string ColHeaderName)
        {
            int idx = -1;

            for (int i = 0; i < chc.Count; i++)
            {
                if (chc[i].Text == ColHeaderName)
                {
                    idx = i;
                    break;
                }
            }
            return(idx);
        }
Esempio n. 3
0
        void ProcessXmlNodeControl(XmlElement node)
        {
            ///根据Name找到目标控件
            Control targetControl = null;

            if (node.Name == "form")
            {
                targetControl = this;
            }
            else
            {
                targetControl = this.Controls.Find(node.Attributes["name"].Value, true)[0];
            }

            ///设置窗体控件的属性
            XmlAttribute attText = node.Attributes["text"];

            if (attText != null && attText.Value != "")
            {
                targetControl.Text = attText.Value.Replace(@"\r\n", "\r\n");

                ///targetControl为Form的时候,设置TabText
                if (targetControl is IDockContent)
                {
                    ((IDockContent)targetControl).DockHandler.TabText = targetControl.Text;
                }
            }

            ///当离开焦点时,控件的值的验证//deleted by zhucai. reason:不需要实时验证
            //XmlAttribute attValidate = node.Attributes["validate"];
            //if (attValidate != null && attValidate.Value != "")
            //{
            //    targetControl.Leave += delegate
            //    {
            //        ValidateService.Validate(attValidate.Value, targetControl);
            //    };
            //}

            ///设置窗体控件的提示文本
            XmlAttribute attHelptip = node.Attributes["helptip"];

            if (attHelptip != null && attHelptip.Value != "")
            {
                targetControl.Enter += delegate
                {
                    _statusLabel.Text = attHelptip.Value;
                };
            }

            ///文件数据绑定
            XmlAttribute attDataBindId = node.Attributes["databindid"];

            if (attDataBindId != null && attDataBindId.Value != "")
            {
                _dicControlDataBindId.Add(targetControl, attDataBindId.Value);

                XmlAttribute attSelectControl = node.Attributes["selectControl"];

                Control selectControl = attSelectControl == null ? null :
                                        this.Controls.Find(attSelectControl.Value, true)[0];

                BindFile(targetControl, selectControl, attDataBindId.Value);
            }

            ///检查elementBind
            string strElementBindName = node.GetAttribute("elementBindName");

            if (!string.IsNullOrEmpty(strElementBindName))
            {
                ///将elementBind数据放入_dicElementBindGroup里
                string strElementBindGroup = node.GetAttribute("elementBindGroup");
                strElementBindGroup = (strElementBindGroup == null ? "" : strElementBindGroup);
                Dictionary <string, ControlNodeData> dicElementBindControl = new Dictionary <string, ControlNodeData>();
                if (!_dicElementBindGroup.TryGetValue(strElementBindGroup, out dicElementBindControl))
                {
                    dicElementBindControl = new Dictionary <string, ControlNodeData>();
                    _dicElementBindGroup.Add(strElementBindGroup, dicElementBindControl);
                }
                BindType bindType    = BindType.Default;
                string   strBindType = node.GetAttribute("elementBindType");
                if (!string.IsNullOrEmpty(strBindType))
                {
                    bindType = (BindType)Enum.Parse(typeof(BindType), strBindType, true);
                }
                dicElementBindControl.Add(strElementBindName, new ControlNodeData(targetControl, node, node.GetAttribute("elementBindFormat"), bindType));
            }

            ///处理Node的子节点
            if (node.HasChildNodes)
            {
                foreach (XmlNode childNode in node.ChildNodes)
                {
                    if (childNode.NodeType == XmlNodeType.Element)
                    {
                        switch (childNode.Name)
                        {
                        case "columns":
                        {
                            int columnIndex = 0;
                            System.Windows.Forms.ListView.ColumnHeaderCollection columns = ((ListView)targetControl).Columns;
                            foreach (XmlNode columnNode in childNode.ChildNodes)
                            {
                                if (columnNode.NodeType != XmlNodeType.Element)
                                {
                                    continue;
                                }
                                if (columnNode.Name == "column")
                                {
                                    columns[columnIndex++].Text = columnNode.Attributes["name"].Value;
                                }
                            }
                            break;
                        }

                        case "condition":
                            break;

                        default:
                            throw new Exception("Control节点出现未知的子节点");
                        }
                    }
                }
            }
        }
 public ColumnHeader64Collection(System.Windows.Forms.ListView.ColumnHeaderCollection Columns)
 {
     this._columns = Columns;
 }
 public static IEnumerable <System.Windows.Forms.ColumnHeader> AsEnumerable(this System.Windows.Forms.ListView.ColumnHeaderCollection source)
 {
     TypeCheckEnumerable(source, (s) => s.AsEnumerable(), (s) => s[0]);
     return(source.Cast <System.Windows.Forms.ColumnHeader>());
 }