How do I allow edit only a particular column in datagridview in windows application using C#

Posted by cmrhema on Stack Overflow See other posts from Stack Overflow or by cmrhema
Published on 2010-04-08T02:49:18Z Indexed on 2010/04/08 2:53 UTC
Read the original article Hit count: 311

Filed under:
|
|

Hi, I want to enable only two columns in the DataGridview to be able to edit. The others should not be allowed to edit. Further I am not directly linking to datasource; I will be doing some thing like this way

DataTable dt = new DataTable();
        dt.Columns.Add("Email");
        dt.Columns.Add("email1");
        for (int i = 0; i < 5; i++)
        {
            DataRow dr = dt.NewRow();
            dr["Email"] = i.ToString();
            dr["email1"] = i.ToString() + "sdf";
            dt.Rows.Add(dr);
        }
        BindingSource bs = new BindingSource();
        bs.DataSource = dt;
        dataGridView1.DataSource = bs;

So which property should I set, that will enable only one column say Email(in the above eg) to be editable.

Thanks

© Stack Overflow or respective owner

Related posts about c#3.0

Related posts about .NET