Solved

How to change column settings from DataReader columns?

Posted on 2009-05-05
4
203 Views
Last Modified: 2012-05-06
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?
0
Comment
Question by:MSFanboy
  • 3
4 Comments
 
LVL 6

Expert Comment

by:Cebik
Comment Utility

foreach (DataGridViewColumn col in dataGridView1.Columns)

    col.ReadOnly = true;

Open in new window

0
 
LVL 6

Accepted Solution

by:
Cebik earned 500 total points
Comment Utility
sorry :)

for (int i=2; i<dataGridView1.Columns.Count; i++)

    dataGridView1.Columns[i].ReadOnly = true;

Open in new window

0
 

Author Comment

by:MSFanboy
Comment Utility
thx a bunch :) totally forgot the i=2 possibility... thought I have to if... the column hehe
0
 
LVL 6

Expert Comment

by:Cebik
Comment Utility
:)
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video discusses moving either the default database or any database to a new volume.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now