DataGridView Readonly on Cell or Row ignored?

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.
 
P

Piotr Szukalski

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
 
B

Ben Gracewood

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top