我在后面的代码中创建了网格。网格有像描述,语言这样的列。问题是这两列的标题文本没有左对齐。网格内的数据为左对齐。
在指定标题列文本的左对齐时是否缺少任何内容?
谢谢。
SPGridView gridView = new SPGridView();
gridView.AutoGenerateColumns = false;
// create the bound fields
SPBoundField boundField;
boundField = new SPBoundField();
boundField.HeaderText = "Description";
boundField.DataField = "Description";
boundField.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
boundField.ItemStyle.Wrap = false;
gridView.Columns.Add(boundField);
boundField = new SPBoundField();
boundField.HeaderText = "Language";
boundField.DataField = "Language";
boundField.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
gridView.Columns.Add(boundField);
gridView.DataSource = dt.DefaultView;
gridView.DataBind();
你还必须设置页眉的对齐方式。
boundField.HeaderStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Left;