public int BuildGridColumns(GridData grid, int columnIndex, ColumnTag tag, int listIndex) { switch (Type) { case EType.List: { grid.InsertColumn(columnIndex, new GridData.Column() { HeaderText = "[" + this.Name, ReadOnly = true, ToolTipText = Name + ":" + Value + ":" + Comment, ColumnTag = tag.Copy(ColumnTag.ETag.ListStart).AddVar(this, -1), }); for (int i = 0; i < grid.RowCount; ++i) { grid.GetCell(columnIndex, i).Value = "["; } if (null == Reference) { throw new Exception("List Reference Not Initialize."); } ++columnIndex; int colAdded = 0; if (listIndex >= 0) { colAdded = Reference.BuildGridColumns(grid, columnIndex, tag.Copy(tag.Tag).AddVar(this, listIndex), -1); } columnIndex += colAdded; grid.InsertColumn(columnIndex, new GridData.Column() { HeaderText = "]" + this.Name, ReadOnly = true, ToolTipText = Name + ": 双击此列增加List Item。", // 这里的 PathLast.ListIndex 是List中最大的Item数量,以后在Bean.Update中修改。 ColumnTag = tag.Copy(ColumnTag.ETag.ListEnd).AddVar(this, 0), }); for (int i = 0; i < grid.RowCount; ++i) { grid.GetCell(columnIndex, i).Value = "]"; } return(colAdded + 2); } /* * case EType.Enum: * { * DataGridViewCell template = new DataGridViewTextBoxCell(); * ColumnTag current = tag.Copy(tag.Tag).AddVar(this, -1); * grid.Columns.Insert(columnIndex, new DataGridViewColumn(template) * { * Name = this.Name, * Width = GridColumnValueWidth, * ToolTipText = Name + ":" + Comment, * Tag = current, * Frozen = false, * AutoSizeMode = DataGridViewAutoSizeColumnMode.None, * }); * // 自动完成来实现enum选择。不使用Combobox. * current.BuildUniqueIndex(grid, columnIndex); * return 1; * } */ default: { ColumnTag current = tag.Copy(tag.Tag).AddVar(this, -1); grid.InsertColumn(columnIndex, new GridData.Column() { HeaderText = Name, ToolTipText = Name + ":" + Comment, ColumnTag = current, }); current.BuildUniqueIndex(grid, columnIndex); return(1); } } }