Hi,
DataGridView is difficult to achieve what you want.
There are some examples of using custom GridView on Github for your reference.
https://github.com/wsn931203/RowMergeView
Form1_Load:
this.rowMergeView1.Columns.Add("1", "Analyst");
this.rowMergeView1.Columns.Add("2", "Date");
this.rowMergeView1.Columns.Add("3", "Current");
this.rowMergeView1.Columns.Add("4", "Previous");
this.rowMergeView1.Columns.Add("5", "Current");
this.rowMergeView1.Columns.Add("6", "Previous");
this.rowMergeView1.Columns.Add("7", "Future");
this.rowMergeView1.Rows.Add("1", "2", "3", "4", "5", "6", "7");
this.rowMergeView1.ColumnHeadersHeight = 40;
this.rowMergeView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
this.rowMergeView1.AddSpanHeader(2, 2, "Price Target");
this.rowMergeView1.AddSpanHeader(4, 3, "Rating");
for (int i = 0; i < this.rowMergeView1.Columns.Count; i++)
{
this.rowMergeView1.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
}
Best regards,
Minxin Yu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.