设置宽度为0即可。
private void hideColumn()
{
   // Set the DataGridTableStyle.MappingName property
   // to the table in the data source to map to.
   ts.MappingName = dataGrid1.DataMember;   // Add it to the datagrid's TableStyles collection
   dataGrid1.TableStyles.Add(ts);   // Hide the first column (index 0)
   dataGrid1.TableStyles[0].GridColumnStyles[0].Width = 0;
}

解决方案 »

  1.   

    // Declare a new DataGridTableStyle in the
    // declarations area of your form.
    DataGridTableStyle ts = new DataGridTableStyle();private void hideColumn()
    {
       // Set the DataGridTableStyle.MappingName property
       // to the table in the data source to map to.
       ts.MappingName = dataGrid1.DataMember;   // Add it to the datagrid's TableStyles collection
       dataGrid1.TableStyles.Add(ts);   // Hide the first column (index 0)
       dataGrid1.TableStyles[0].GridColumnStyles[0].Width = 0;
    }
      

  2.   

    谢谢,问题解决了,不过程序要稍微改一下DataGridTableStyle ts = new DataGridTableStyle();
    private void hideColumn()
    {
        ts.MappingName = UserDataTable.TableName;
       
        DataGridTextBoxColumn UserNameCol = new DataGridTextBoxColumn();
        UserNameCol.MappingName = "字段标题";   
        UserNameCol.HeaderText  = "字段标题";
        ts.GridColumnStyles.Add( UserNameCol );
        ts.GridColumnStyles[0].Width = 0;
        dataGrid1.TableStyles.Add(ts);
    }