private void frmSample17_Load(object sender, System.EventArgs e) { grid1.Redim(100, 40); grid1.FixedColumns = 0; grid1.FixedRows = 0; grid1[0, 0] = new SourceGrid.Cells.Header(null); for (int c = 1; c < grid1.ColumnsCount; c++) { SourceGrid.Cells.ColumnHeader header = new SourceGrid.Cells.ColumnHeader("Header " + c.ToString()); header.AutomaticSortEnabled = false; //header.ColumnSelectorEnabled = true; //header.ColumnFocusEnabled = true; grid1[0, c] = header; } Random rnd = new Random(); for (int r = 1; r < grid1.RowsCount; r++) { grid1[r, 0] = new SourceGrid.Cells.RowHeader("Header " + r.ToString()); for (int c = 1; c < grid1.ColumnsCount; c++) { if (rnd.NextDouble() > 0.20) { grid1[r, c] = new SourceGrid.Cells.Cell(r * c, typeof(int)); } else { grid1[r, c] = null; } } } var selection = grid1.Selection as SelectionBase; for (int i = 0; i < 100; i++) { grid1[i, 0] = new Cell(i); } for (int i = 30; i < 70; i++) { grid1.Rows.ShowRow(i, false); } }
private void frmSample17_Load(object sender, System.EventArgs e) { grid1.Redim(100, 40); grid1.FixedColumns = 0; grid1.FixedRows = 0; grid1[0,0] = new SourceGrid.Cells.Header(null); for (int c = 1; c < grid1.ColumnsCount; c++) { SourceGrid.Cells.ColumnHeader header = new SourceGrid.Cells.ColumnHeader("Header " + c.ToString()); header.AutomaticSortEnabled = false; //header.ColumnSelectorEnabled = true; //header.ColumnFocusEnabled = true; grid1[0, c] = header; } Random rnd = new Random(); for (int r = 1; r < grid1.RowsCount; r++) { grid1[r,0] = new SourceGrid.Cells.RowHeader("Header " + r.ToString()); for (int c = 1; c < grid1.ColumnsCount; c++) { if (rnd.NextDouble() > 0.20) { grid1[r,c] = new SourceGrid.Cells.Cell(r*c, typeof(int)); } else grid1[r,c] = null; } } var selection = grid1.Selection as SelectionBase; for (int i = 0; i < 100; i++) grid1[i, 0] = new Cell(i); for (int i = 30; i < 70; i++) grid1.Rows.ShowRow(i, false); }
private void SetColumnsAndRows(string[] columns, string[] rows, Grid grid) { if (grid.InvokeRequired) { SetNumberOfColumnsAndRows d = SetColumnsAndRows; Invoke(d, columns, rows, grid); } else { grid.Rows.Clear(); grid.Columns.Clear(); grid.Rows.Insert(0); grid.Columns.Insert(0); for (int row = 1; row <= rows.Length; row++) { grid.Rows.Insert(row); grid[row, 0] = new RowHeader(rows[row - 1]); for (int column = 1; column <= columns.Length; column++) { if (row == 1) { grid.Columns.Insert(column); grid[0, column] = new SourceGrid.Cells.ColumnHeader(columns[column - 1]); } grid[row, column] = new Cell(); grid[row, column].View = new SourceGrid.Cells.Views.Cell(); } } grid.AutoSizeCells(); } }
public virtual void Init() { SourceGrid.Cells.Views.Cell v_Normal = new SSIT.PropertyBase.Resources().V_Common; SourceGrid.Cells.Views.Cell v_ReadOnly = new SSIT.PropertyBase.Resources().V_Common; v_ReadOnly.BackColor = System.Drawing.SystemColors.Control; Redim(Fields.Count + FixedRows, HeaderCount + SampleCount + 2); this[0, 0] = new Cells.Header("序号"); this[0, 1] = new Cells.Header("检验项目"); this[0, 2] = new Cells.Header("项目类型"); this[0, 3] = new Cells.Header("值类型"); this[0, 4] = new Cells.Header("检验标准"); this[0, 5] = new Cells.Header("合格率要求(%)"); for (int i = 0; i < Fields.Count; i++) { int rowindex = i + FixedRows; this[rowindex, 1] = new Cells.Header(Fields[i].FieldName); this[rowindex, 2] = new Cells.Header(Fields[i].CheckType); this[rowindex, 3] = new Cells.Header(ValueTypeClass.GetStringValue(Fields[i].ValueType)); this[rowindex, 4] = new Cells.Header(Fields[i].StandardStr); this[rowindex, 5] = new Cells.Header(Fields[i].QualifyRate); this[rowindex, 0] = new Cells.RowHeader(i + 1); this[rowindex, 0].Tag = Fields[i]; } for (int i = 0; i < SampleCount; i++) { this[0, i + HeaderCount] = new Cells.ColumnHeader(string.Format("第 {0} 个样本", i + 1)); } SSIT.PropertyBase.Resources res = new SSIT.PropertyBase.Resources(); for (int j = 0; j < Fields.Count; j++) { if (Fields[j].ValueType == ValueTypeEnum.Selection) { if (!string.IsNullOrWhiteSpace(Fields[j].StandardStr)) { string[] strs = Fields[j].StandardStr.Split(new char[] { '|', '|' });// SSITEncode.Common.STRING.Split(Fields[j].StandardStr, "||"); List <string> list = new List <string>(); if (strs != null) { foreach (string str in strs) { if (!string.IsNullOrWhiteSpace(str)) { list.Add(str); } } } eSelection = res.EncodeComboBox(list, false); } else { eSelection = res.EncodeComboBox(new string[] { string.Empty }, false); } } for (int i = HeaderCount; i < SampleCount + HeaderCount; i++) { Cells.Cell cell = new SourceGrid.Cells.Cell(); if (!Fields[j].ReadOnly) { switch (Fields[j].ValueType) { case ValueTypeEnum.Logic: cell.Editor = eLogic; break; case ValueTypeEnum.Number: cell.Editor = eNum; break; case ValueTypeEnum.Selection: cell.Editor = eSelection; break; } //cell.View = v_Normal; } else { cell.Editor = eNumReadOnly; // cell.View = v_ReadOnly; } cell.View = new SSIT.PropertyBase.Resources().V_Standard; this[j + FixedRows, i] = cell; } } //合格率 合格判定 this[0, HeaderCount + SampleCount] = new Cells.Header("合格率(%)"); this[0, HeaderCount + SampleCount + 1] = new Cells.Header("合格判定"); for (int i = 0; i < Fields.Count; i++) { int rowindex = i + FixedRows; this[rowindex, HeaderCount + SampleCount] = new Cells.Header(); this[rowindex, HeaderCount + SampleCount + 1] = new Cells.Header(); } this.Columns.AutoSize(true); this.Selection.SelectionMode = SourceGrid.GridSelectionMode.Cell; }