public void BuildUniqueIndex(GridData grid, int columnIndex) { for (int i = 0; i < grid.RowCount; ++i) { var cell = grid.GetCell(columnIndex, i); AddUniqueIndex(cell.Value, cell); } }
public int BuildGridColumns(GridData grid, int columnIndex, ColumnTag tag, int listIndex) { int colAdded = 0; foreach (var v in _Variables) { colAdded += v.BuildGridColumns(grid, columnIndex + colAdded, tag, listIndex); } // 这里创建的列用来新增。 grid.InsertColumn(columnIndex + colAdded, new GridData.Column() { HeaderText = ",", ReadOnly = true, ToolTipText = "双击增加列", // 使用跟List一样的规则设置ListIndex,仅用于Delete List Item,此时这个Bean肯定在List中。 ColumnTag = tag.Copy(ColumnTag.ETag.AddVariable).AddVar(new VarDefine(this, ""), listIndex >= 0 ? listIndex : 0), }); for (int i = 0; i < grid.RowCount; ++i) { grid.GetCell(columnIndex + colAdded, i).Value = ","; } ++colAdded; return(colAdded); }
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); } } }