none
crystal report Group Column RRS feed

All replies

  • Hi Dipak Sutare,

    Thank you for posting here.

    According to your question is more related to Winform, I will move it to  Windows Forms General forum for suiteble support.

    The Visual C# discuss and ask the C# programming language, IDE, libraries, samples and tools.

    If you have some grammar or code errors, please feel free to contact us. We will try our best to give you a solution.

    Thanks for your understanding and cooperation.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, May 19, 2017 6:07 AM
  • Hi Dipak,

    From your form screenshot, if you use the datagridview to display the data, then please refer to the following demo:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    
    namespace WinFormApplication20170519_
    {
        public partial class FrmDgvMergeCell : Form
        {
            public FrmDgvMergeCell()
            {
                InitializeComponent();
            }
    
            private void FrmDgvMergeCell_Load(object sender, EventArgs e)
            {
                DataTable dt = new DataTable();
                dt.Columns.Add("1");
                dt.Columns.Add("2");
                dt.Columns.Add("3");
                dt.Columns.Add("4");
                dt.Rows.Add("A", "AA", "5000", "5000");
                dt.Rows.Add("A", "AAA", "5000", "5000");
                dt.Rows.Add("B", "BB", "5000", "5000");
                dt.Rows.Add("B", "BBB", "5000", "5000");
                dt.Rows.Add("C", "CC", "5000", "5000");
    
                this.dataGridView1.DataSource = dt;
            }
    
            private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
            {
                if (e.ColumnIndex == 0 && e.RowIndex != -1)
                {
                    using
                        (
                        Brush gridBrush = new SolidBrush(this.dataGridView1.GridColor),
                        backColorBrush = new SolidBrush(e.CellStyle.BackColor)
                        )
                    {
                        using (Pen gridLinePen = new Pen(gridBrush))
                        {
                            e.Graphics.FillRectangle(backColorBrush, e.CellBounds);
                            if (e.RowIndex > dataGridView1.Rows.Count - 2 || dataGridView1.Rows[e.RowIndex + 1].Cells[e.ColumnIndex].Value == null)
                            {
                                return;
                            }
                            if (e.RowIndex < dataGridView1.Rows.Count - 1 &&
                            dataGridView1.Rows[e.RowIndex + 1].Cells[e.ColumnIndex].Value.ToString() !=
                            e.Value.ToString())
                                e.Graphics.DrawLine(gridLinePen, e.CellBounds.Left,
                                e.CellBounds.Bottom - 1, e.CellBounds.Right - 1,
                                e.CellBounds.Bottom - 1);
                            
                            e.Graphics.DrawLine(gridLinePen, e.CellBounds.Right - 1,
                                e.CellBounds.Top, e.CellBounds.Right - 1,
                                e.CellBounds.Bottom);
                            
                            if (e.Value != null)
                            {
                                if (e.RowIndex > 0 &&
                                dataGridView1.Rows[e.RowIndex - 1].Cells[e.ColumnIndex].Value.ToString() ==
                                e.Value.ToString())
                                { }
                                else
                                {
                                    e.Graphics.DrawString((String)e.Value, e.CellStyle.Font,
                                        Brushes.Black, e.CellBounds.X + 2,
                                        e.CellBounds.Y + 5, StringFormat.GenericDefault);
                                }
                            }
                            e.Handled = true;
                        }
                    }
                }
            }
        }
    }
    

    If you use the crystal report, I suggest you post your thread to the Crystal Reports Forum for dedicated information.

    Best Regards,

    Stanly


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Proposed as answer by Stanly Fan Tuesday, May 23, 2017 10:14 AM
    Friday, May 19, 2017 10:09 AM