private TSGrid GetGridConfig() { TSGrid hsGrid = new TSGrid { Columns = new List <TSGridColumn>() }; TSGridColumn col1 = new TSGridColumn { Name = "name", Text = "Name", ColumnType = TSGridColumnType.Text, ValueType = Model.Data.DataValueType.String, Width = 60, Visible = 1 }; hsGrid.Columns.Add(col1); TSGridColumn col2 = new TSGridColumn { Name = "combobox", Text = "ComboBox", ColumnType = TSGridColumnType.ComboBox, ValueType = Model.Data.DataValueType.String, Width = 60, Visible = 1 }; hsGrid.Columns.Add(col2); return(hsGrid); }
private TSGrid GetGridConfig() { TSGrid hsGrid = new TSGrid { Columns = new List <TSGridColumn>() }; TSGridColumn col1 = new TSGridColumn { Name = "name", Text = "Name", ColumnType = TSGridColumnType.Text, ValueType = Model.Data.DataValueType.String, Width = 60, Visible = 1 }; hsGrid.Columns.Add(col1); TSGridColumn col2 = new TSGridColumn { Name = "id", Text = "Id", ColumnType = TSGridColumnType.Text, ValueType = Model.Data.DataValueType.String, Width = 60, Visible = 1 }; hsGrid.Columns.Add(col2); TSGridColumn col3 = new TSGridColumn { Name = "age", Text = "Age", ColumnType = TSGridColumnType.NumericUpDown, ValueType = Model.Data.DataValueType.Int, Width = 60, Visible = 1 }; hsGrid.Columns.Add(col3); return(hsGrid); }
private Model.Data.DataTable LoadData(out List <TSGridColumn> columns) { Model.Data.DataTable dataTable = new Model.Data.DataTable { Rows = new List <Model.Data.DataRow>(), ColumnIndex = new Dictionary <string, int>() }; columns = new List <TSGridColumn>(); Random ran = new Random(); for (int i = 0; i < 15; i++) { Model.Data.DataRow dataRow = new Model.Data.DataRow { Columns = new List <Model.Data.DataValue>() }; for (int j = 0; j < 10; j++) { Model.Data.DataValue dataValue = new Model.Data.DataValue(); dataValue.Type = Model.Data.DataValueType.Int; dataValue.Value = ran.Next(150); if (i == 0) { string name = string.Format("T-{0}", j); if (!dataTable.ColumnIndex.ContainsKey(name)) { dataTable.ColumnIndex.Add(name, j); } TSGridColumn column = new TSGridColumn(); column.Name = name; column.Text = name; columns.Add(column); } dataRow.Columns.Add(dataValue); } dataTable.Rows.Add(dataRow); } return(dataTable); }
public static TSGrid GetGridConfig() { TSGrid hsGrid = new TSGrid { Columns = new List <TSGridColumn>() }; TSGridColumn col1 = new TSGridColumn { Name = "name", Text = "Name", ColumnType = TSGridColumnType.Text, ValueType = Model.Data.DataValueType.String, Width = 60, Visible = 1 }; hsGrid.Columns.Add(col1); TSGridColumn col2 = new TSGridColumn { Name = "id", Text = "Id", ColumnType = TSGridColumnType.ComboBox, ValueType = Model.Data.DataValueType.String, Width = 120, Visible = 1 }; hsGrid.Columns.Add(col2); TSGridColumn col3 = new TSGridColumn { Name = "id_source", Text = "IdSource", ColumnType = TSGridColumnType.Text, ValueType = Model.Data.DataValueType.String, Width = 60, Visible = 0 }; hsGrid.Columns.Add(col3); return(hsGrid); }
public static void AddColumns(TSDataGridView dgv, TSGrid hsGrid) { if (dgv == null) { throw new ArgumentNullException("dgv"); } if (hsGrid == null) { throw new ArgumentNullException("hsGrid"); } List <TSGridColumn> columns = hsGrid.Columns; DataGridViewColumn[] gridColumns = new DataGridViewColumn[columns.Count]; for (int i = 0, count = columns.Count; i < count; i++) { TSGridColumn col = columns[i]; DataGridViewColumn column = null; switch (col.ColumnType) { case TSGridColumnType.CheckBox: { column = new DataGridViewCheckBoxColumn(); } break; case TSGridColumnType.Image: { column = new DataGridViewImageColumn(); column.Tag = col.DefaultValue; } break; case TSGridColumnType.Text: { column = new DataGridViewTextBoxColumn(); } break; case TSGridColumnType.ComboBox: { column = new DataGridViewComboBoxColumn(); } break; case TSGridColumnType.NumericUpDown: { var numericCell = new DataGridViewNumericUpDownColumn(); numericCell.Minimum = 0; numericCell.Increment = 1; numericCell.Maximum = 100; column = numericCell; } break; default: { column = new DataGridViewTextBoxColumn(); } break; } if (col.ValueType == DataValueType.Float) { column.DefaultCellStyle.Format = "##0.000"; } column.HeaderText = col.Text; column.Name = col.Name; column.Width = col.Width; column.ReadOnly = (col.ReadOnly != 0) ? true : false; column.Visible = (col.Visible != 0) ? true : false; gridColumns[i] = column; if (hsGrid.Background == 1 && column.ReadOnly) { column.DefaultCellStyle.BackColor = Color.FromArgb(244, 243, 234); } } dgv.Columns.AddRange(gridColumns); }