Solved

Using ReadOnly with a DataGridView?

Posted on 2014-12-16
2
91 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
2 Comments
 
LVL 32

Accepted Solution

by:
it_saige earned 500 total points
Comment Utility
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
Comment Utility
Thanks for the clarification!
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

763 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

9 Experts available now in Live!

Get 1:1 Help Now