/// <summary> /// 显示联接表 /// </summary> private void ShowJoinTableData() { DataTable Schema = TableData.GetSchema(); //绑定数据时保证显示第一行,以免报错“System.ArgumentOutOfRangeException: Invalid low bound argument” if (FpSpread_Panel.Rows.Count > 0) { FpSpread.ShowRow(FpSpread.GetActiveRowViewportIndex(), 0, VerticalPosition.Top); } FpSpread_Panel.Reset(); FpSpread_Panel.RowHeaderVisible = false; FpSpread_Panel.RowCount = Schema.Rows.Count; FpSpread_Panel.ColumnCount = Schema.Columns.Count; Graphics g = FpSpread.CreateGraphics(); FarPoint.Win.Spread.CellType.TextCellType CellType = new FarPoint.Win.Spread.CellType.TextCellType(); CellType.Multiline = true; CellType.WordWrap = true; for (int k = 0; k < Schema.Columns.Count; k++) { FpSpread_Panel.Columns[k].CellType = CellType; FpSpread_Panel.Columns[k].VerticalAlignment = CellVerticalAlignment.Center; FpSpread_Panel.Columns[k].HorizontalAlignment = CellHorizontalAlignment.Center; FpSpread_Panel.Columns[k].Tag = Schema.Columns[k].ColumnName; FpSpread_Panel.ColumnHeader.Columns[k].Label = string.Concat(Schema.Columns[k].ColumnName, "(", TableData.GetDataTypeAbbr(k), ")"); FpSpread_Panel.ColumnHeader.Columns[k].Width = 250; } g.Dispose(); foreach (DataRow Row in Schema.Rows) { int RowIndex = Schema.Rows.IndexOf(Row); foreach (System.Data.DataColumn Col in Schema.Columns) { int ColIndex = Schema.Columns.IndexOf(Col); FpSpread_Panel.Cells[RowIndex, ColIndex].Value = Row[Col.ColumnName].ToString(); } } AutoColumnsWidth(FpSpread_Panel, AutoSizeFlags.Contents, 150); }
/// <summary> /// 显示数据表 /// </summary> private void ShowArrayTableData() { DataTable Schema = TableData.GetSchema(); //绑定数据时保证显示第一行,以免报错“System.ArgumentOutOfRangeException: Invalid low bound argument” if (FpSpread_Panel.Rows.Count > 0) { FpSpread.ShowRow(FpSpread.GetActiveRowViewportIndex(), 0, VerticalPosition.Top); } FpSpread_Panel.Reset(); FpSpread_Panel.RowHeaderVisible = false; FpSpread_Panel.RowCount = Schema.Rows.Count; FpSpread_Panel.ColumnCount = Schema.Columns.Count; Graphics g = FpSpread.CreateGraphics(); for (int k = 0; k < Schema.Columns.Count; k++) { FpSpread_Panel.Columns[k].VerticalAlignment = CellVerticalAlignment.Center; FpSpread_Panel.Columns[k].HorizontalAlignment = CellHorizontalAlignment.Center; FpSpread_Panel.Columns[k].Tag = Schema.Columns[k].ColumnName; FpSpread_Panel.ColumnHeader.Columns[k].Label = string.Concat(Schema.Columns[k].ColumnName, "(", TableData.GetDataTypeAbbr(k), ")"); FpSpread_Panel.ColumnHeader.Columns[k].Width = g.MeasureString(FpSpread_Panel.ColumnHeader.Columns[k].Label, FpSpread.Font).Width + 20; if (Schema.Columns[k].DataType == typeof(string)) { FpSpread_Panel.Columns[k].CellType = TextType; } else if (Schema.Columns[k].DataType == typeof(long)) { FpSpread_Panel.Columns[k].CellType = IntegerType; } else if (Schema.Columns[k].DataType == typeof(double)) { FpSpread_Panel.Columns[k].CellType = FloatType; } else if (Schema.Columns[k].DataType == typeof(DateTime)) { FpSpread_Panel.Columns[k].CellType = DateType; } } g.Dispose(); for (int j = 0; j < FpSpread_Panel.Columns.Count; j++) { for (int i = 0; i < FpSpread_Panel.Rows.Count; i++) { if (FpSpread_Panel.Columns[j].Tag != null) { FpSpread_Panel.Cells[i, j].Value = Schema.Rows[i][FpSpread_Panel.Columns[j].Tag.ToString()]; } } } if (FpSpread_Panel.ColumnHeader.Columns.Count > 0) { AutoColumnsWidth(FpSpread_Panel, 0, FpSpread_Panel.ColumnHeader.Columns.Count - 1, AutoSizeFlags.Contents, 150); } }