GridView 项目文本换行

发布于 2024-07-07 18:02:41 字数 680 浏览 5 评论 0原文

我有一个在运行时动态创建的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

讽刺将军 2024-07-14 18:02:41

当我想要控制换行时,自动换行 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

錯遇了你 2024-07-14 18:02:41

您可以将其添加到网格视图中 -
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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文