DataGridView Readonly on Cell or Row ignored?

  • Thread starter Thread starter Ben Gracewood
  • Start date Start date
B

Ben Gracewood

Hi

I'm feeling like a total idiot at the moment. We're building an app in
..NET 2.0 beta 2, and no matter how hard I try, I can't get a
DataGridView to accept ReadOnly = true on a cell or row.

Columns work fine, and stepping through the code clearly shows that
e.g. myDataGridView.Rows[0].ReadOnly = true; is being called, and yet
the row is definitely not read only.

Any ideas? Is this something missing in Beta 2, or am I missing some
simple step?

Many thanks,
Ben Gracewood.
 
Hi
I'm feeling like a total idiot at the moment. We're building an app in
.NET 2.0 beta 2, and no matter how hard I try, I can't get a
DataGridView to accept ReadOnly = true on a cell or row.

I don't use .NET 2.0, but it seems like DataGridView is similar to .NET
1.1 DataView - try setting 'AllowEdit' property to 'false'. It locks all
the view not a single row however...

Cheers,
Piotrek
 
OK, I've found the problem.
Despite the fact that the Row in question is accessible in the OnLoad
event of the Form, setting the ReadOnly property doesn't 'stick'.

If you set readonly at a later time (e.g. when the DataGridView gets
focus) works OK.

I think this must be a bug, because the DataGridView.Rows[0] should
really return an index out of bounds error if the Row[0] is not ready
to be configured.
 
Back
Top