I have dynamically built a datagrid in a TabControl. I am now adding a button to allow the user to edit the information. The button shows up just fine, but when I click on the button the Click event is not being called. Below is my code for adding the button.
// The tabpage.
TabPage newPage = new TabPage(drCurrent[0].ToString());
newPage.Text = drCurrent[0].ToString();
DataGridView grid = new DataGridView();
grid.AllowUserToAddRows = false;
grid.AllowUserToDeleteRows = false;
DataGridViewButtonColumn bcol = new DataGridViewButtonColumn();
bcol.HeaderText = "Edit";
bcol.Text = "Edit";
bcol.Name = "btnClickMe";
bcol.Width = 50;
bcol.UseColumnTextForButtonValue = true;
grid.Columns.Add(bcol);
grid.Dock = DockStyle.Fill;
grid.DataSource = table;
newPage.Controls.Add(grid);
// Add to the tab control.
tabMain.TabPages.Add(newPage);
What do I need to do to get the click even working?
// The tabpage.
TabPage newPage = new TabPage(drCurrent[0].ToString());
newPage.Text = drCurrent[0].ToString();
DataGridView grid = new DataGridView();
grid.AllowUserToAddRows = false;
grid.AllowUserToDeleteRows = false;
DataGridViewButtonColumn bcol = new DataGridViewButtonColumn();
bcol.HeaderText = "Edit";
bcol.Text = "Edit";
bcol.Name = "btnClickMe";
bcol.Width = 50;
bcol.UseColumnTextForButtonValue = true;
grid.Columns.Add(bcol);
grid.Dock = DockStyle.Fill;
grid.DataSource = table;
newPage.Controls.Add(grid);
// Add to the tab control.
tabMain.TabPages.Add(newPage);
What do I need to do to get the click even working?