如何允许编辑只能在datagridview的在Windows应用程序中的特定列?应用程序、编辑、只能在、datagridview

由网友(你脑壳有屎)分享简介:我想启用只有两个在DataGridView列可以编辑。其他不应该被允许进行编辑。而且我并没有直接链接到数据源;我会做一些事情一样这样I want to enable only two columns in the DataGridview to be able to edit.The others shoul...

我想启用只有两个在DataGridView列可以编辑。 其他不应该被允许进行编辑。 而且我并没有直接链接到数据源; 我会做一些事情一样这样

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.

推荐答案

其他列的只读属性设置为

(您可能需要通过收集回路,并使用如果语句)

(You'll probably need to loop through the Columns collection and use an if statement)

阅读全文

相关推荐

最新文章