0

我有在后面的代码中创建的网格。网格有描述、语言等列。问题是这 2 列的标题文本没有左对齐。网格内的数据左对齐。

我是否缺少任何东西来指定标题列文本的左对齐。

谢谢。

                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();
4

1 回答 1

1

您还必须设置标题的对齐方式。

boundField.HeaderStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Left;
于 2012-05-04T09:15:08.573 回答