//--------------------------------------------------------------------- public void Clear() { _columns.Clear(); _cacheColumnIndexes.Clear(); }
private void buttonOK_Click(object sender, EventArgs e) { DataGridViewColumn[] cols = new DataGridViewColumn[_tbl.Rows.Count]; for (int i = 0; i < _tbl.Rows.Count; i++) { Type t = typeof(string); try { string tx = Convert.ToString(_tbl.Rows[i][2]); if (string.Compare(tx, "Integer", StringComparison.OrdinalIgnoreCase) == 0) { t = typeof(int); } else if (string.Compare(tx, "Decimal", StringComparison.OrdinalIgnoreCase) == 0) { t = typeof(double); } else if (string.Compare(tx, "DateTime", StringComparison.OrdinalIgnoreCase) == 0) { t = typeof(DateTime); } else if (string.Compare(tx, "Time", StringComparison.OrdinalIgnoreCase) == 0) { t = typeof(TimeSpan); } else if (string.Compare(tx, "Boolean", StringComparison.OrdinalIgnoreCase) == 0) { t = typeof(bool); } } catch { } string name = _tbl.Rows[i][0].ToString(); string text = _tbl.Rows[i][1].ToString(); for (int k = 0; k < _cols.Count; k++) { if (string.Compare(_cols[k].DataPropertyName, name, StringComparison.OrdinalIgnoreCase) == 0) { if (t.Equals(_cols[k].ValueType)) { cols[i] = _cols[k]; cols[i].HeaderText = text; break; } } } if (cols[i] == null) { if (t.Equals(typeof(bool))) { cols[i] = new DataGridViewCheckBoxColumn(); } else { cols[i] = new DataGridViewTextBoxColumn(); } cols[i].HeaderText = text; cols[i].DataPropertyName = name; cols[i].Name = name; cols[i].ValueType = t; } } _cols.Clear(); // Type[] tps = new Type[cols.Length]; for (int i = 0; i < cols.Length; i++) { tps[i] = cols[i].ValueType; } _cols.AddRange(cols); for (int i = 0; i < _cols.Count; i++) { _cols[i].ValueType = tps[i]; } this.DialogResult = DialogResult.OK; }
public override void Clear() { _base.Clear(); }
/// <summary> /// Clears the collection /// </summary> public void Clear() { _columns.Clear(); }
private void InitializeColumns(DataGridViewColumnCollection columns) { columns.Clear(); DataGridViewColumn column; // // clmIndex // column = new DataGridViewTextBoxColumn(); columns.Add(column); column.DataPropertyName = "Id"; column.HeaderText = "Id"; column.Name = "clmIndex"; column.ReadOnly = true; column.Width = 35; column.ToolTipText = "Index"; // // clmFrec // column = new DataGridViewTextBoxColumn(); columns.Add(column); column.DataPropertyName = "Title"; column.HeaderText = "Frec"; column.Name = "clmFrec"; column.ReadOnly = true; column.Width = 166; column.ToolTipText = "Frec"; // // clmTime // column = new DataGridViewTextBoxColumn(); columns.Add(column); column.DataPropertyName = "TimeString"; column.HeaderText = "Start"; column.Name = "clmTime"; column.ReadOnly = true; column.Width = 75; column.ToolTipText = "Start time"; // // clmWait // column = new DataGridViewTextBoxColumn(); columns.Add(column); column.DataPropertyName = "ResponceWaitTime"; column.HeaderText = "Wait"; column.Name = "clmWait"; column.ReadOnly = true; column.Width = 60; column.ToolTipText = "Waiting time to responce"; // // clmTable // column = new DataGridViewTextBoxColumn(); columns.Add(column); column.DataPropertyName = "TableName"; column.HeaderText = "Table"; column.Name = "clmTable"; column.ReadOnly = true; column.Width = 120; column.ToolTipText = "Table name"; // // clmSession // column = new DataGridViewTextBoxColumn(); columns.Add(column); column.DataPropertyName = "SessionId"; column.HeaderText = "Session"; column.Name = "clmSession"; column.ReadOnly = true; column.Width = 130; column.ToolTipText = "Project session"; column.Visible = false; // // clmThread // column = new DataGridViewTextBoxColumn(); columns.Add(column); column.DataPropertyName = "Thread"; column.HeaderText = "Thread"; column.Name = "clmThread"; column.ReadOnly = true; column.Width = 45; column.ToolTipText = "Thread"; column.Visible = false; // // clmParseDuration // column = new DataGridViewTextBoxColumn(); columns.Add(column); column.DataPropertyName = "ParseDuration"; column.HeaderText = "Parse duration"; column.Name = "clmParseDuration"; column.ReadOnly = true; column.Width = 120; column.ToolTipText = "Frec parse duration"; column.Visible = false; // // clmServer // column = new DataGridViewTextBoxColumn(); columns.Add(column); column.DataPropertyName = "Server"; column.HeaderText = "Server"; column.Name = "clmServer"; column.ReadOnly = true; column.Width = 120; column.ToolTipText = "Server"; column.Visible = false; }