Click here to Skip to main content
15,897,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all

I have a datagrid with one check box column and 3 data columns
now i want like which ever check box i check then in that row on cell of a particular column should be editable

e.g. my datagrid is like this

check     name  group  value
checkbox  aaa     A      5
checkbox  bbb     B      10


So now if i check the first check box then only the cell with value 5 should be editable.and in uncheck it will be non-editable.

Please tell me how to do this..
Posted

check     name  group  value
checkbox  aaa     A      5
checkbox  bbb     B      10


there are two way to accomplish your task that is....
1) just write on the chekbox checked event of the data gridview ...
VB
DataGridView1.Row([rowinedx]).Cell([cellindex]).ReadOnly=True


2) second is check for checkbox is checked or not on CellClick event of datagridview
and write same
VB
DataGridView1.Row([rowinedx]).Cell([cellindex]).ReadOnly=True



All the best...............
 
Share this answer
 
Hi
just paste the following code in the CellContentClick event of the datagridview

VB
'check if the clicked column is the right one
If e.ColumnIndex = 0 Then

   'change cell readonly property according to checkbox state
    DataGridView1.Rows(e.RowIndex).Cells(3).ReadOnly = Not _                     DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value

End If
 
Share this answer
 

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