How to change column settings from DataReader columns?

Hello,

I have a datagridview with 8 columns.

2 columns are created manually and the other 6 are from a DataReader assigned to the datagridviews datasource.

The 2 columns I have set the property ReadOnly = false; because the user must enter data, but the other 6 columns are editable too, how can I stop that? User is not allowed to enter data here. How can I access the 6  columns after the DataReader is bound to the datagridviews datasource?
MSFanboyAsked:
Who is Participating?
 
CebikCommented:
sorry :)

for (int i=2; i<dataGridView1.Columns.Count; i++)
    dataGridView1.Columns[i].ReadOnly = true;

Open in new window

0
 
CebikCommented:

foreach (DataGridViewColumn col in dataGridView1.Columns)
    col.ReadOnly = true;

Open in new window

0
 
MSFanboyAuthor Commented:
thx a bunch :) totally forgot the i=2 possibility... thought I have to if... the column hehe
0
 
CebikCommented:
:)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.