If I create a DatagridView in this way:
DataTable table = new DataTable();
//DataTable is filled with values here...
DataGridView grid = new DataGridView();
foreach (DataColumn column in table.Columns)
{
grid.Columns.Add(column.ColumnName, column.ColumnName);
}
grid.DataSource = table;
If I want to implement the following event:
private void dataGridView1_EditingControlShowing(object sender,
DataGridViewEditingControlShowingEventArgs e)
{
e.Control.KeyPress -= new KeyPressEventHandler(Column1_KeyPress);
if (dataGridView1.CurrentCell.ColumnIndex == 0) //Desired Column
{
TextBox tb = e.Control as TextBox;
if (tb != null)
{
tb.KeyPress += new KeyPressEventHandler(Column1_KeyPress);
}
}
}
How do I do ???
Each event represents an independent method that refers to the datagridView, but how do you do this if the datagridview was created at the point of code in the load form method ???