// Order has changed, need to be reflected in the header struture public void ReorganizeHeader() { int i = 0; foreach (DataGridViewColumn col in _theDataGrid.Columns) { string colName = col.Name; string colNameIndex = _theDataGrid.Columns[i++].Name; } // CCellHeaderVector tCurrentCellHeaderVector = _theMatrix._cellHeaderVector; CCellHeaderVector tCellHeaderVector = new CCellHeaderVector(); i = 0; foreach (DataGridViewColumn col in _theDataGrid.Columns.OfType <DataGridViewColumn>().OrderBy(x => x.DisplayIndex)) { string colName = col.Name; string colNameIndex = _theDataGrid.Columns[i++].Name; CCellHeader tCellHeader = _theMatrix._cellHeaderVector.GetCellHeaderByColName(colName); tCellHeaderVector.AddCellHeader(tCellHeader); } // replace witht the new one _theMatrix._cellHeaderVector = tCellHeaderVector; }
private void button4_Click(object sender, EventArgs e) { CCellHeader tCellHeader = _theMatrix._cellHeaderVector.GetCellHeaderByColName(textBoxName.Text); tCellHeader._header = textBoxHeader.Text; tCellHeader._script = richTextBoxScriptHeader.Text; tCellHeader._description = richTextBoxHeaderDescr.Text; }
private void AddDetailToDialogHeader(CCellHeader pCellHeader) { if (pCellHeader is object) { textBoxName.Text = pCellHeader._name; textBoxHeader.Text = pCellHeader._header; richTextBoxScriptHeader.Text = pCellHeader._script; richTextBoxHeaderDescr.Text = pCellHeader._description; } }
// Clik on header private void dataGridViewDyn_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) { int colIndex = e.ColumnIndex; var col = dataGridViewDyn.Columns[colIndex]; string colName = col.Name; CCellHeader tCellHeader = _theMatrix._cellHeaderVector.GetCellHeaderByColName(colName); AddDetailToDialogHeader(tCellHeader); }
// Add a column public void AddHeaderColumn() { CCellHeader tCellHeader = new CCellHeader(); using (var modal = new FormDialogHeader(tCellHeader)) { modal.ShowDialog(); if (modal.DialogResult == DialogResult.OK) { _theMatrix._cellHeaderVector.AddCellHeader(tCellHeader); AddHeaderToGrid(); RefreshGrid(); } } }
// add a column private void buttonAddColumn_Click(object sender, EventArgs e) { CCellHeader tCellHeader = new CCellHeader(); using (var modal = new FormDialogHeader(tCellHeader)) { modal.ShowDialog(); if (modal.DialogResult == DialogResult.OK) { _theMatrix._cellHeaderVector.AddCellHeader(tCellHeader); AddCellToGrid(dataGridViewDyn, _theMatrix._cellHeaderVector); } else if (modal.DialogResult == DialogResult.Cancel) { } } }
// Event relay - double click on heaser // Double click on header bring the column customization window public void ColumnHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { int colIndex = e.ColumnIndex; var col = _theDataGrid.Columns[colIndex]; string colName = col.Name; CCellHeader tCellHeader = _theMatrix._cellHeaderVector.GetCellHeaderByColName(colName); using (var modal = new FormDialogHeader(tCellHeader)) { modal.ShowDialog(); if (modal.DialogResult == DialogResult.OK) { col.Name = tCellHeader._name; col.HeaderText = tCellHeader._header; } } }
public FormDialogHeader(CCellHeader pCellHeader) { InitializeComponent(); _cellHeader = pCellHeader; textBoxName.Text = _cellHeader._name; textBoxHeader.Text = _cellHeader._header; richTextBoxScriptHeader.Text = _cellHeader._script; richTextBoxHeaderDescr.Text = _cellHeader._description; if (_cellHeader._type == ECellType.Input) { radioButtonInupt.Checked = true; radioButtonScript.Checked = false; } else { radioButtonInupt.Checked = false; radioButtonScript.Checked = true; } VerifyRadioButton(); }
// add cols dynagrids private void buttonAddField_Click(object sender, EventArgs e) { //this.dataGridViewDyn.Columns.Add("newColumnName", "Column Name in Text"); this.dataGridViewDyn.Rows.Clear(); this.dataGridViewDyn.Columns.Clear(); CCellHeader newCellHeader1 = new CCellHeader(1, "col1", "header1", "Descr1", "script1"); CCellHeader newCellHeader2 = new CCellHeader(2, "col2", "header2", "Descr2", "script2"); CCellHeader newCellHeader3 = new CCellHeader(3, "col3", "header3", "Descr3", "script3"); CCellHeader newCellHeader4 = new CCellHeader(4, "col4", "header4", "Descr4", "script4"); CCellHeader newCellHeader5 = new CCellHeader(5, "col5", "header5", "Descr5", "script5"); CCellHeaderVector _cellHeaderVector = new CCellHeaderVector(); _cellHeaderVector.AddCellHeader(newCellHeader1); _cellHeaderVector.AddCellHeader(newCellHeader2); _cellHeaderVector.AddCellHeader(newCellHeader3); _cellHeaderVector.AddCellHeader(newCellHeader4); _cellHeaderVector.AddCellHeader(newCellHeader5); AddCellToGrid(dataGridViewDyn, _cellHeaderVector); }