C# DataGridView合并单元格

C# DataGridView合并单元格,c#,datagridview,merge,cells,C#,Datagridview,Merge,Cells,我面临DataGridView组件的问题。 我知道DataGridView组件不能合并单元格 有没有办法像上面的例子那样合并两行中的两个单元格 ************************** * First Name | Last Name * * ---------- |---------- * * | David * * Smith |---------- * * | Anna * *--

我面临DataGridView组件的问题。 我知道DataGridView组件不能合并单元格

有没有办法像上面的例子那样合并两行中的两个单元格

************************** * First Name | Last Name * * ---------- |---------- * * | David * * Smith |---------- * * | Anna * *------------|---------- * * Michael | Daniel * ************************** etc. ************************** *名|姓* * ---------- |---------- * *|大卫* *史密斯--------* *|安娜* *------------|---------- * *迈克尔·丹尼尔* ************************** 等
请试着这样做

        this.Paint += new PaintEventHandler(dataGridView1_Click); //Call event while loading

        private void dataGridView1_Click(object sender, PaintEventArgs e)
        {
        Font fnt = new Font("Arial", 10, FontStyle.Bold, GraphicsUnit.Point);
        Rectangle rct1 = new Rectangle((dataGridView1.GetColumnDisplayRectangle(0, true).X), (dataGridView1.GetColumnDisplayRectangle(0, true).Y + dataGridView1.Columns[0].HeaderCell.ContentBounds.Height + 8), dataGridView1.GetColumnDisplayRectangle(0, true).Width - 1, (dataGridView1.GetRowDisplayRectangle((dataGridView1.Rows.Count - 1), true).Top - dataGridView1.GetRowDisplayRectangle((dataGridView1.Rows.Count - 1), true).Height));
        // Create string to draw.
        String drawString = "Sample Text";
        // Create font and brush.
        Font drawFont = new Font("Arial", 16);
        SolidBrush drawBrush = new SolidBrush(Color.Black);
        // Create point for upper-left corner of drawing.
        float x = 150.0F;
        float y =  50.0F;
        // Set format of string.
        StringFormat drawFormat = new StringFormat();
        drawFormat.FormatFlags = StringFormatFlags.DirectionVertical;
        // Draw string to screen.

        e.Graphics.FillRectangle(Brushes.White, rct1);
        e.Graphics.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat);
        Rectangle rct =new Rectangle();
        rct = dataGridView1.GetRowDisplayRectangle(3, true)
        rct.Height -= 1;
        SizeF s =new  SizeF();
            s= e.Graphics.MeasureString("HORINZONTAL TEXT", dataGridView1.Font);
        float lefts = (rct.Width / 2) - (s.Width / 2);
        float tops  = rct.Top + ((rct.Height / 2) - (s.Height / 2));
        e.Graphics.FillRectangle(Brushes.White, rct);
        e.Graphics.DrawString("HORINZONTAL TEXT", fnt, Brushes.Black, 2, tops);
       }