?
Solved

Using ReadOnly with a DataGridView?

Posted on 2014-12-16
2
Medium Priority
?
110 Views
Last Modified: 2014-12-16
The following code isn't working:

dataGridView1.ReadOnly = True
dataGridView1.Columns(1).ReadOnly = False

Open in new window


The above code doesn't allow me to enter data manually in Column 1 of the dgv.

I have a dgv that contains 15 columns and I only want to 2 of them to be able to enter data manually. I'm doing the above method just to save lines of code (not that big of deal really). Just wondered if there was a way of doing this without having to set all the Columns.ReadOnly = True?

Thanks!
0
Comment
Question by:BlakeMcKenna
[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
2 Comments
 
LVL 34

Accepted Solution

by:
it_saige earned 2000 total points
ID: 40503202
A cell is read-only if the value of the ReadOnly property is true for the cell, the cell's row, the cell's column, or the DataGridView.
Source

Implies that a cell is read-only if it or any of it's parent containers have the ReadOnly property set to true.

So to answer your question directly, you will have to explicitly define the ReadOnly property for each of the cells that you want to be read-only and set the ReadOnly property of the GridView to false.

-saige-
0
 

Author Closing Comment

by:BlakeMcKenna
ID: 40503256
Thanks for the clarification!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
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…
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

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