Solved

Using ReadOnly with a DataGridView?

Posted on 2014-12-16
2
108 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 500 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

691 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