Click here to Skip to main content
12,079,489 members (63,231 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: VB 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
dcba1894
Comments
Shahin Khorshidnia 27-Mar-12 5:19am
   
Please tag your question.
WinForm? ASP.Net? WPF? Silver Light? other...?
smp 234 27-Mar-12 5:51am
   
Winform
smp 234 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 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 27-Mar-12 6:05am
   
It also not working. I have already tried it.
Member 10360247 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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web04 | 2.8.160212.1 | Last Updated 20 Mar 2013
Copyright © CodeProject, 1999-2016
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