I want that when I check the checkbox in the datagrid view my button that is disabled at the beginning will be activated after I want the selected lines to be inserted in a table.
Asked
Active
Viewed 45 times
-4
-
2If you are in such a hurry you should give **all** informations to speed up response. Are you working with WPF? Then add the *wpf* tag – Sir Rufo Mar 14 '17 at 10:17
-
The following post might help you http://stackoverflow.com/questions/11843488/datagridview-checkbox-event – Luci Mar 14 '17 at 10:18
-
from where you are populating data for your grid ??? – J.SMTBCJ15 Mar 14 '17 at 11:01
-
From the database – maroua Mar 14 '17 at 11:05
1 Answers
-1
I don't know if you are using the standard DataGridView from .NET but I will assume you do. Also the assumption goes that your checkbox is not binded to a model. Subscribe to the dataGridView_CellClick event and handle you case and handle there the business.
private void dataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 0/*myColumn*/ && e.RowIndex == 0 /*myRow*/)
{
myButton.Enable = true;
//do other business
}
}
Also the dataGridView_CellContentClick event can be used depending on what you need.

Diizzy
- 534
- 4
- 12
-
yes. Your column in which you hold the checkbox control. Maybe the dataGridView_CellContentClick is more suitable for your case. The CellClick event will be fired even if the use will not click in the checkbox but the click is in the cell. – Diizzy Mar 14 '17 at 10:41
-
Sorry for the inconvenience I want the user to just select a line in the datagridview – maroua Mar 14 '17 at 10:47
-
Your description says otherwise "I want that when I check the checkbox in the datagrid view my button that is disabled at the beginning will be activated ". Plus you can use the dataGridView.SelectedRows to get the collection of selected rows. – Diizzy Mar 14 '17 at 10:55
-
-
-