Click here to Skip to main content
15,886,963 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone,


I want to merge some of the rows in my datagridview and I'm using this article.



When I load my datagridview, I want to change the type of my columns so that they can have the "rowspan" and "colspan".


How can I do it?

What I have tried:

Here's how I load my datagridview :
C#
dataGridView1.DataSource = null;
                dataGridView1.Rows.Clear();
                SqlConnection cn = new SqlConnection();
                SqlCommand cmd = new SqlCommand();
                cn.ConnectionString = @"CONNECTION STRING"; 
                cmd.Connection = cn;
                cmd.Connection.Open();
                cmd.CommandText = $"SELECT * FROM Table where column3!= '' "; 
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataTable dt = new DataTable();

                
                
              
                da.Fill(dt);


                BindingSource source = new BindingSource();
                source.DataSource = dt;
                dataGridView1.DataSource = dt;
Posted
Updated 8-Jul-23 1:00am
Comments
Dave Kreskowiak 7-Jul-23 14:07pm    
Ask the author of the article in the forum at the bottom of the article.
Sandeep Mewara 8-Jul-23 0:12am    
Everything is mentioned in the article. Did you follow it? If so, where did you got stuck?
LiterallyGutsFromBerserk 8-Jul-23 6:13am    
I managed to get unstuck by copying the columns I wanted to edit to new columns, and then removing the old. Works like a charm!

1 solution

Posting OP's solution to get it off unanswered list.

OP resolved it by:
Quote:
I managed to get unstuck by copying the columns I wanted to edit to new columns, and then removing the old. Works like a charm!
 
Share this answer
 
Comments
LiterallyGutsFromBerserk 8-Jul-23 7:23am    
Thanks for posting it instead of e and sorry for the disturbance. I'm currently neither at work nor at home, so I tend to forget about my phone haha.
Sandeep Mewara 10-Jul-23 1:06am    
:thumbsup:

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900