Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a datagridview
in which three columns
1- int value in datagridviewtextbox
2- int value in datagridviewtextbox
3- checkbox

i want when i check any checkbox
its(row) corresponding 1st column value should be added in global variable 'TOTAL'(which is pre defined)
Posted
Comments
abbaspirmoradi 25-Nov-13 7:06am    
ok do this..

 
Share this answer
 
hi Try this sample code..

C#
private void Form1_Load(object sender, EventArgs e)
       {
           DataTable dt = new DataTable();
           dt.Columns.Add("boolvalue", typeof(bool));
           dt.Rows.Add(true);
           dt.Rows.Add(false);
           dt.Rows.Add(true);
           dataGridView1.DataSource = dt;
       }

       private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
       {
           if( e.ColumnIndex == 0) // 0 is the first column, specify the valid index of ur gridview
           {
           bool value = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].EditedFormattedValue;
       }
 
Share this answer
 
Comments
Member 13055644 13-Mar-17 7:32am    
salut , j'ai un datagridview que je l'a rempli depuis la base de données aprés j'ai ajouter un checkbox dans la datagridview et je veux quand je check une ligne il fallait qu'une button sera activé (dans le load est désactivé ) mais dans la fin de la datagridview il y a une ligne vide avec un checkbox et dans chaque fois je clique sur le checkbox de la ligne vide il m'ajoute une autre ligne avec un checkbox ....

merci en avance :)
Karthik_Mahalingam 13-Mar-17 7:46am    
sir i dont understand the lang you wrote, pls translate it to english and post it.
Member 13055644 13-Mar-17 8:06am    
Karthik Bangalore OK
Member 13055644 13-Mar-17 8:06am    
Hi, I have a datagridview that I filled in from the database after I added a checkbox in the datagridview and I want when I check a line it needed a button to be activated (in the load is disabled) ) But in the end of the datagridview there is an empty line with a checkbox and every time I click on the checkbox of the empty line it adds another line with a checkbox ....

thank you in advance :)
Karthik_Mahalingam 13-Mar-17 8:08am    
there will be a property to add new row, disable that..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900