Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
How to make Column read only in vb.net datagridview? I have 5 Column in datagrid. I want to edit only 3rd Column not all. I set datagirdview.Column(2).readonly=false
and datagridview property set to readonly true. But its not working. I can't edit that 3rd Column.
Posted 26-Mar-12 23:26pm
dcba1893
Comments
Shahin Khorshidnia at 27-Mar-12 5:19am
   
Please tag your question.
WinForm? ASP.Net? WPF? Silver Light? other...?
smp 234 at 27-Mar-12 5:51am
   
Winform
smp 234 at 28-Mar-12 1:41am
   
How to make Column read only in vb.net datagridview? I have 5 Column in datagrid. I want to edit only 3rd Column not all. I set datagirdview.Column(2).readonly=false
and datagridview property set to readonly true. But its not working. I can't edit that 3rd Column.
smp 234 at 28-Mar-12 1:48am
   
I have tried it by using
dataGridView1.Columns("ColumnName").ReadOnly = False
this property but it also not working

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi,
 
You cannot make one column as readonly if datagridview on a whole is set as readonly.
So, firstly you need to set that to
dataGridView1.ReadOnly =false;
 
than set all the columns in your code as readonly.
 
foreach (DataGridViewColumn dgvc in dgSearchedResults.Columns)
                    {
                        dgvc.ReadOnly = true;
                    }
 
follow that by setting the readonly property of required column to false.
 
dataGridView1.Columns("ColumnName").ReadOnly = false;
  Permalink  
v3
Comments
smp 234 at 27-Mar-12 6:05am
   
It also not working. I have already tried it.
Member 10360247 at 30-Jul-14 6:04am
   
It works.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 400
1 Jochen Arndt 190
2 Richard MacCutchan 135
3 DamithSL 95
4 Garth J Lancaster 90
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,032
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,220


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 20 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100