Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a DataGridView in a C# Windows Forms app displaying records from a query.

How do I make it so that certain rows (i.e., that have the status field set to 'closed') are read-only?

Brian
Posted

1 solution

Well as far as I know you can make a row readonly by:

MIDL
dataGridView1.Rows[1].ReadOnly = true;


With a for-loop read all the rows in your gridview, if the status field of the specific row is closed, get its row index and set its readonly property to "true".

For further information see:

MSDN Datagridview.Readonly property[^]

C# datagridview readonly row,column...[^]
 
Share this answer
 
Comments
shaikh-adil 2-Jan-13 2:48am    
+5
Sergey Alexandrovich Kryukov 23-Jan-14 18:57pm    
Tested, that's correct, a 5 :-)
—SA
lesvaches 21-Feb-18 3:22am    
This does NOT work

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