要求列头和行的内容都是垂直显示。之前搜索了一下,没找到解决方法,在这里向各位大大请教。。
如下图所示:
如下图所示:
解决方案 »
- “类库”作为“WCF服务”,寄宿在IIS7
- 用SubWindow:NativeWindow重绘PorgressBar后,无法设置ProgressBar的属性了
- 求教,两处简单问题,谢谢~
- [100分]通过PostMessage自动弹出优盘(在线等)
- 求助:VS 2008需要下载Internet Explore WebControl软件包?
- 一页打印多个DataGridview代码,希望大家来帮忙优化下!
- 如何将ListView控件选中的项向上移动或向下移动 C#
- 紧急求助一个在excel中画曲线图的问题!
- 有没有一个工具,可以将数据库中的Table 转换为 C# 类的??
- 求高手帮助正则表达式
- 第一次发帖,谁能教我winform怎么打包
- C#.net IIS 发布网站的问题
2还有自己加换行符。
3采用模板列放个LABEL,然后通过样式设置。gridview自己好象没有垂直显示的属性。
http://social.msdn.microsoft.com/forums/en-US/winformsdesigner/thread/df986ca1-b230-4018-ac2f-55fa1349fe36/
内容的话记得cell有个mode,可以设置的内容按宽度来显示(多了就换行)到底是哪个我忘记了,你自己找找吧
{
DataTable dt = new DataTable(); dt.Columns.Add("c1");
dt.Columns.Add("c2"); for (int j = 0; j < 10; j++)
{
dt.Rows.Add("aaaaaaaaaa", "bbbbbbbbbbbbbbbb");
}
this.dataGridView2.DataSource = dt; for (int j = 0; j < 10; j++)
{
//这地方把0换成1应该就行,可惜不行。。不知道咋回事
int height = TextRenderer.MeasureText(
this.dataGridView2[0, j].Value.ToString(),
this.dataGridView2.DefaultCellStyle.Font).Width;
this.dataGridView2.Rows[j].Height = height;
} this.dataGridView2.CellPainting += new
DataGridViewCellPaintingEventHandler(dataGridView2_CellPainting);
}
void dataGridView2_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
if (e.ColumnIndex == 0 && e.RowIndex > -1 && e.Value != null)
{
e.Paint(e.CellBounds, DataGridViewPaintParts.All & ~DataGridViewPaintParts.ContentForeground); StringFormat sf = new StringFormat();
sf.Alignment = StringAlignment.Center;
sf.LineAlignment = StringAlignment.Center;
sf.FormatFlags = StringFormatFlags.DirectionVertical;
e.Graphics.DrawString(e.Value.ToString(), e.CellStyle.Font, new SolidBrush(e.CellStyle.ForeColor), e.CellBounds, sf);
e.Handled = true; } }
这个你应该考虑用水晶报表来显示。或是其他报表设计类方法。
如果是GridView套个CSS样式就可以了。
这个真没用过,帮忙顶一个