vb.net 2008 Datagridview Disable Edit on colunm

i use datagridview on vb.net 2008 .how to not allow user to edit only column 1 and column 12
aaronthamAsked:
Who is Participating?
 
Sreedhar VengalaConnect With a Mentor Sr. Consultant - Business IntelligenceCommented:
VB:
dataGridView1.Columns(1).[ReadOnly] = True
dataGridView1.Columns(12).[ReadOnly] = True
0
 
NicksonKohCommented:
Did you try setting the field to just read only as in ReadOnly="True"?
0
 
Sreedhar VengalaSr. Consultant - Business IntelligenceCommented:
           p2pDataContext p = new p2pDataContext();
           
            dataGridView1.DataSource = (from a in p.Stockpiles select a).ToList();
            dataGridView1.Columns[0].ReadOnly = true;
            dataGridView1.Columns[1].ReadOnly = true;
0
 
Sreedhar VengalaSr. Consultant - Business IntelligenceCommented:
for col 1 and 12 to make readlnly (non editable)
dataGridView1.Columns[1].ReadOnly = true;
dataGridView1.Columns[12].ReadOnly = true;
0
 
NicksonKohCommented:
Here's how u do in design mode.
<Columns>
    <asp:BoundField DataField="Column1" HeaderText="Column1" ReadOnly="True" SortExpression="Column1" />
    <asp:BoundField DataField="Column2" HeaderText="Column2"  SortExpression="Column2" />
</Columns>

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.