选dataGrid的属性,其中有一项可以修改成edit就可以了

解决方案 »

  1.   

    DataGrid各列默认都是可以编辑的。
    属性生成器--->列---->设置各"绑定列"(在下面),把ReadOnly 选中就可以了。
      

  2.   

    DataGridTextBoxColumn TxtCol =new DataGridTextBoxColumn();
    this.datagrid1.TableStyles.Clear();
    this.datagrid1.DataSource=this.dataView;
    DataGridTableStyle ts= new DataGridTableStyle();
    ts.MappingName =yourtablename

    TxtCol =new DataGridTextBoxColumn();
    TxtCol.MappingName ="col1";
    TxtCol.HeaderText ="col1";
    TxtCol.Width =80;
    TxtCol.ReadOnly=true;
    ts.GridColumnStyles.Add(TxtCol);TxtCol =new DataGridTextBoxColumn();
    TxtCol.MappingName ="col2";
    TxtCol.HeaderText ="col2";
    TxtCol.Width =80;
    TxtCol.ReadOnly=false;
    ts.GridColumnStyles.Add(TxtCol);this.datagrid1.TableStyles.Add(ts);
    col1不能编辑,col2能编辑