DataGridTableStyle ts = new DataGridTableStyle(true);
ts.MappingName = dataView .Tables[0].TableName;
this.SUBJECT.TableStyles.Clear();
this.SUBJECT.TableStyles.Add(ts);
ts.GridColumnStyles[0].Width=0;
ts.GridColumnStyles[0].HeaderText = "科目编号";

解决方案 »

  1.   

    我遇到过一次直接绑定DataTable就可以得到你要的结果,但DataSet不行。我也没搞懂为啥,楼主急的话可先把数据源改为DataTable,以后再慢慢研究。
      

  2.   

    呵呵,把楼上的中和起来,终于做出来了。谢谢~~~~好感谢哟~~~~~
    我把代码贴出来,希望像我一样的菜菜鸟能够少走弯路。:)
    o(@_@)ostring MySelectStr = "";
    MySelectStr = "select * from SUBJECT";
    OleDbConnection myConnection = DataConnection.Instance.GetConnection();
    DataSet dataView = new DataSet();
    OleDbDataAdapter myAdapter = new OleDbDataAdapter(MySelectStr,myConnection);
    myAdapter.Fill(dataView);
    DataTable myDataTable = dataView.Tables[0];
    this.SUBJECT.DataSource = myDataTable;DataGridTableStyle ds = new DataGridTableStyle(true);
    ds.DataGrid = this.SUBJECT;
    ds.MappingName = myDataTable.TableName;this.SUBJECT.TableStyles.Clear();
    this.SUBJECT.TableStyles.Add(ds);ds.GridColumnStyles[0].HeaderText = "编号";
    ds.GridColumnStyles[0].Width = 100;
    ds.GridColumnStyles[0].MappingName = "SUBJECTID";
    ds.GridColumnStyles[1].HeaderText = "科目名称";
    ds.GridColumnStyles[1].Width = 100;
    ds.GridColumnStyles[1].MappingName = "SUBJECTNAME";
    myConnection.Close();