要求列头和行的内容都是垂直显示。之前搜索了一下,没找到解决方法,在这里向各位大大请教。。
如下图所示:

解决方案 »

  1.   

    1是把列宽设置的小点,这样自己就会垂直显示。
    2还有自己加换行符。
    3采用模板列放个LABEL,然后通过样式设置。gridview自己好象没有垂直显示的属性。
      

  2.   


    http://social.msdn.microsoft.com/forums/en-US/winformsdesigner/thread/df986ca1-b230-4018-ac2f-55fa1349fe36/
      

  3.   

    1楼的典型的不看楼主的问题,别人问DataGridView他回答GridView去了每列的宽度必须设置小点,这样列头就设置好了
    内容的话记得cell有个mode,可以设置的内容按宽度来显示(多了就换行)到底是哪个我忘记了,你自己找找吧
      

  4.   

    这个倒是靠谱。。不过不知道为什么第二列不能垂直显示。。我修改了下也不行。。 private void Form2_Load(object sender, EventArgs e)
            {
                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;            }        }
      

  5.   

    DataGridView不是制表图的。
    这个你应该考虑用水晶报表来显示。或是其他报表设计类方法。
      

  6.   

    DataGridView 刚开始确实没看清!
    如果是GridView套个CSS样式就可以了。
    这个真没用过,帮忙顶一个