Wrox Programmer Forums
|
Visual Studio 2008 For discussing Visual Studio 2008. Please post code questions about a specific language (C#, VB, ASP.NET, etc) in the correct language forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Studio 2008 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 9th, 2012, 03:53 PM
Authorized User
 
Join Date: Sep 2007
Posts: 62
Thanks: 0
Thanked 0 Times in 0 Posts
Default VB.Net DataGridView Cell Editable

I’m using VB.Net.
I’m using DataGridView with ColumnType = DataGridViewTextBoxColumn.
I have 3 columns. Column1, Column2, Column3.
For example:
Code:
Column1          Column2          Column3
1                        AA                AAA
2                        BB                EDIT
3                        CC                CCC

If column3’s value = “EDIT”, then I need to edit only that cell.
Here for example: i need to make the Column3’s second cell to be readonly=false.
So i cannot make any changes to (1, AA, AAA), (3, CC, CCC) and (2, BB). Need to make changes only EDIT cell.
I tried this code. CountR is the row in which EDIT values is there.
Code:
DataGridView1.Item(2, CountR).ReadOnly = False 

Code:
DataGridView1.Rows(CountR).Cells(2).ReadOnly = False

But this makes every cell in column editable.
Is there a way i can make some cells editable in column?
If you know how to do it, please help me. if you can provide an example, then that will be so helpful.
Thanks in Advance.
 
Old March 11th, 2012, 04:41 AM
Authorized User
 
Join Date: Sep 2007
Posts: 62
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i think i'm executing that code multiple times with different row indexes.

So i try this code, and it's working...

Code:
                For Each r As DataGridViewRow In DataGridView1.Rows
                    If r.Cells(3).Value.ToString = "EDIT" Then
                        r.Cells(3).ReadOnly = False
                    Else
                        r.Cells(3).ReadOnly = True
                    End If
                Next





Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing a cell in a DataGridView Martin Woodhouse C# 2008 aka C# 3.0 12 October 3rd, 2008 08:42 AM
datagridview cell validation kscase Pro Visual Basic 2005 1 July 12th, 2007 07:21 AM
RadioButton in DataGridView (VB.net 2005 Express) baberamin VB.NET 0 December 21st, 2006 03:30 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.