Click here to Skip to main content
15,884,177 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here I want to make only those cells editable for what Checkbox is marked and but unable to make non editable which are not even checked mark. Please help me User can't edit any cells which are not checked mark in Checkbox

What I have tried:

C#
foreach (DataGridViewRow dgvrow in dataGridView1.SelectedRows)
            {
                if (Convert.ToBoolean(dgvrow.Cells["chkbox"].Value) == true)
                {

                    LOB = dgvrow.Cells["lOBDataGridViewTextBoxColumn"].Value.ToString();
                    POL_NUM = dgvrow.Cells["polNumDataGridViewTextBoxColumn"].Value.ToString();
                    POL_Effdate = Convert.ToDateTime(dgvrow.Cells["polEffDtDataGridViewTextBoxColumn"].Value);
                    POL_Expdate = Convert.ToDateTime(dgvrow.Cells["polExpDtDataGridViewTextBoxColumn"].Value);
                    tbl_pol_coll_agmt_dtls_id = Convert.ToInt32(dgvrow.Cells["TBL_POL_COLL_AGMT_DTLS_ID"].Value);


                    if (MessageBox.Show("Would like to update the click yes!!",
                        "Input Data", MessageBoxButtons.YesNo) ==
                        System.Windows.Forms.DialogResult.Yes)
                    {
                        collServCall.UpdateInputPolicyData(tbl_pol_coll_agmt_dtls_id, LOB, POL_NUM, POL_Effdate, POL_Expdate);
                    }
                }
            }
Posted
Updated 6-Jun-22 3:07am
v2

1 solution

Maybe you can disable rows like this:
dataGridView1.Rows[index].ReadOnly = true;

See: C# DataGridView Read Only Columns and Rows[^]
 
Share this answer
 
Comments
0x01AA 6-Jun-22 9:18am    
Or something like this: Dynamically set datagridview cells readonly[^], Solution 1 ;)
RickZeeland 6-Jun-22 9:51am    
That's a brilliant answer!
why didn't I think of that ...

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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