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
Solved

How to change column settings from DataReader columns?

Posted on 2009-05-05
4
209 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
ID: 24304634

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

Open in new window

0
 
LVL 6

Accepted Solution

by:
Cebik earned 500 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

809 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