?
Solved

How to change column settings from DataReader columns?

Posted on 2009-05-05
4
Medium Priority
?
212 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 6

Expert Comment

by:Cebik
ID: 24304634

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

Open in new window

0
 
LVL 6

Accepted Solution

by:
Cebik earned 2000 total points
ID: 24304658
sorry :)

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

Open in new window

0
 

Author Comment

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

Expert Comment

by:Cebik
ID: 24304980
:)
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

770 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