GridView 项目文本换行
我有一个在运行时动态创建的 GridView 控件。 我正在创建这样的所有列。
foreach (GridColumnConfig column in columns)
{
BoundField boundField = new BoundField();
boundField.HeaderText = column.Title;
boundField.DataField = column.FieldName;
boundField.SortExpression = column.FieldName;
boundField.ItemStyle.Wrap = false;
boundField.ItemStyle.Width = new Unit(column.Width, UnitType.Pixel);
boundField.ItemStyle.HorizontalAlign = TextToAlign(column.Align);
m_GenericListView.Grid.Columns.Add(boundField);
}
然而,即使我已指定该项目不换行,它在 IE6 中仍然会这样做。 在 FireFox 中,它只是创建一个非常宽的列,即使已经指定了宽度,也可能不是这样。
有什么方法可以真正控制 GridView 中的这些宽度和换行列吗?
I have a GridView control that I am dynamically creating at runtime. I am creating all the columns like this.
foreach (GridColumnConfig column in columns)
{
BoundField boundField = new BoundField();
boundField.HeaderText = column.Title;
boundField.DataField = column.FieldName;
boundField.SortExpression = column.FieldName;
boundField.ItemStyle.Wrap = false;
boundField.ItemStyle.Width = new Unit(column.Width, UnitType.Pixel);
boundField.ItemStyle.HorizontalAlign = TextToAlign(column.Align);
m_GenericListView.Grid.Columns.Add(boundField);
}
However even though I have specified the item not to wrap text it still does so in IE6. In FireFox it just creates a very wide column which is probably not what either, even though the width has been specified.
Is there any way to really control these widths and wrapping columns in a GridView ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当我想要控制换行时,自动换行 CSS 样式适合我。 这是一个很好地涵盖了它的讨论。
http://bytes.com/forum/thread627827.html
The word-wrap CSS style works for me when I want to control wrapping. Here's a discussion that pretty well covers it.
http://bytes.com/forum/thread627827.html
您可以将其添加到网格视图中 -
Style="white-space: nowrap"
Gridview 没有名为 style 的属性,但您可以添加它并且它会起作用。
或者你可以声明一个 CSS 类并将其分配给 gridview
you can add this to the gridview -
Style="white-space: nowrap"
Gridview doesnt have a property called style, but you can add it and it will work.
Or you can declare a CSS class and assign it to the gridview