Link to home
Start Free TrialLog in
Avatar of aarontham
aarontham

asked on

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
Avatar of NicksonKoh
NicksonKoh
Flag of Singapore image

Did you try setting the field to just read only as in ReadOnly="True"?
           p2pDataContext p = new p2pDataContext();
           
            dataGridView1.DataSource = (from a in p.Stockpiles select a).ToList();
            dataGridView1.Columns[0].ReadOnly = true;
            dataGridView1.Columns[1].ReadOnly = true;
for col 1 and 12 to make readlnly (non editable)
dataGridView1.Columns[1].ReadOnly = true;
dataGridView1.Columns[12].ReadOnly = true;
ASKER CERTIFIED SOLUTION
Avatar of Sreedhar Vengala
Sreedhar Vengala
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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