Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
have problem for bind custom row and column in datagridview c# windows form

Hi, I have a datagridview in my winform and i have a sql table information (figure 1) :
figure1[^]

i want to bind those informations to datagridview like figure 2 :

figuer2[^]

how i can do that?
can i have dynamic code? for example when add another car code to table ,datagrid automaticaly add new info
I would appreciate if u helped me with this.

What I have tried:

//this code work fine to create datagridview for figure 1 :
str = " select * from V_ProductPlanYears where 1=1  ";
               SqlDataAdapter SqlDa = new SqlDataAdapter(str, conDb10);
               DataTable dt = new DataTable();
               SqlDa.Fill(dt);
               dgvProductPlanning.DataSource = dt;
Posted
Updated 2-Aug-22 23:26pm
v4

1 solution

 
Share this answer
 
Comments
Hassan20 3-Aug-22 8:54am    
Thank you for answering, I thought , the only way to get the answer, use nested Loop(For Loop)
do you have any example for that way ?
of course i am going to read something about Pivot and Unpivot in Sql to resolve my issue too

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