Click here to Skip to main content
14,836,169 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Comments
Shahin Khorshidnia 27-Mar-12 5:19am
   
Please tag your question.
WinForm? ASP.Net? WPF? Silver Light? other...?
dcba1 27-Mar-12 5:51am
   
Winform
dcba1 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.
dcba1 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

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
C#
dataGridView1.ReadOnly =false;


than set all the columns in your code as readonly.

C#
foreach (DataGridViewColumn dgvc in dgSearchedResults.Columns)
                    {
                        dgvc.ReadOnly = true;
                    }


follow that by setting the readonly property of required column to false.

C#
dataGridView1.Columns("ColumnName").ReadOnly = false;
   
v3
Comments
dcba1 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)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900