设置宽度为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;
}
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;
}
// 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;
}
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);
}