C# 网格视图 ASP .NET 中标题文本的垂直显示
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/230035/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Vertical display of Header Text in Grid View ASP .NET
提问by user21968
Is there a way to display the headerText of the Grid View vertically?
有没有办法垂直显示网格视图的 headerText ?
http://img371.imageshack.us/img371/4813/testyk6.jpg
http://img371.imageshack.us/img371/4813/testyk6.jpg
I hope the above link works
我希望上面的链接有效
Thanks
谢谢
回答by Travis Collins
I believe you'd have to use images. Either created at design time, or using a HttpHandler to generate images at run-time if they need to be dynamic. Make all of your fields use TemplateFields and place the image in the HeaderTemplate. Kind of tedious, but it's the only way I can think. Perhaps some third party grid controls can handle this.
我相信你必须使用图像。要么在设计时创建,要么在运行时使用 HttpHandler 生成图像(如果它们需要是动态的)。使您的所有字段都使用 TemplateFields 并将图像放置在 HeaderTemplate 中。有点乏味,但这是我唯一能想到的方法。也许某些第三方网格控件可以处理这个问题。
回答by John Dunagan
Silverlight can do this (as can Flash, I'm sure). CSS3 will support it. But graphic text is the way to go right now.
Silverlight 可以做到这一点(Flash 也可以,我敢肯定)。CSS3 将支持它。但是图形文本是现在要走的路。
You can use any of several text-hiding techniques in CSS to show the text for accessible browsers, yet display the graphic (with text arranged vertically) for sighted users.
您可以使用 CSS 中的多种文本隐藏技术中的任何一种来为可访问的浏览器显示文本,同时为视力正常的用户显示图形(文本垂直排列)。
回答by Forgotten Semicolon
Stu Nichollshas an interesting HTML/CSS technique, if a bit HTML verbose. However, it doesn't do the word rotation that you're looking for. Just throwing out another option.
Stu Nicholls有一个有趣的 HTML/CSS 技术,虽然有点 HTML 冗长。但是,它不会执行您要查找的单词轮换。只是抛出另一种选择。
回答by Travis Collins
If you don't mind an IE only solution, you could use some of the css filters that IE supports. Something like this:
如果您不介意仅使用 IE 的解决方案,则可以使用 IE 支持的一些 css 过滤器。像这样的东西:
<div style="width:100%; filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=3);">
This text is rotated 90 degrees.
</div>
回答by Simon Keep
I've done it IE using the following CSS although it might be limited to browser, version etc...
我已经使用以下 CSS 完成了 IE,尽管它可能仅限于浏览器、版本等......
writing-mode: tb-rl; filter: flipv fliph
写作模式:tb-rl;过滤器:flipvfliph
回答by Keith
In IE7+ you can use the DX transform:
在 IE7+ 中,您可以使用 DX 变换:
writing-mode: tb-rl;
filter: flipv fliph;
In older IE (for the poor souls still stuck with it):
在较旧的 IE 中(对于仍然坚持使用它的可怜人):
filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
In Safari/Chrome (anything webkit based) you can use the transform:
在 Safari/Chrome(任何基于 webkit 的)中,您可以使用转换:
-webkit-transform: rotate(270deg);
The latest FX builds have an equivalent:
最新的 FX 版本具有等效项:
-moz-transform: rotate(270deg);
But that's not mainstream yet.
但这还不是主流。
I've been trying to do this with graphic text, but have a few problems.
我一直在尝试用图形文本来做到这一点,但有一些问题。
回答by Leon Botha
I used a break (br) command between each letter
我在每个字母之间使用了一个 break (br) 命令
回答by annie
/*Do this in a loop for each header cell so Cells[0] to cells[however many] and however long the string is so use length properties to get the actual length of the text string */
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
StringBuilder vtxt = new StringBuilder();
vtxt.Append(GridView1.HeaderRow.Cells[0].Text.ToString().Substring(0,1));
vtxt.Append("<br />");
vtxt.Append(GridView1.HeaderRow.Cells[0].Text.ToString().Substring(1, 1));
vtxt.Append("<br />");
vtxt.Append(GridView1.HeaderRow.Cells[0].Text.ToString().Substring(2, 1));
vtxt.Append("<br />");
vtxt.Append(GridView1.HeaderRow.Cells[0].Text.ToString().Substring(3, 1));
vtxt.Append("<br />");
vtxt.Append(GridView1.HeaderRow.Cells[0].Text.ToString().Substring(4, 1));
vtxt.Append("<br />");
vtxt.Append(GridView1.HeaderRow.Cells[0].Text.ToString().Substring(5, 1));
vtxt.Append("<br />");
vtxt.Append(GridView1.HeaderRow.Cells[0].Text.ToString().Substring(6, 1));
vtxt.Append("<br />");
vtxt.Append(GridView1.HeaderRow.Cells[0].Text.ToString().Substring(7, 1));
GridView1.HeaderRow.Cells[2].Text = vtxt.ToString();
}