Click here to Skip to main content
15,885,309 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Note it is windows application

Code as follows in the form load,


C#
          int iRow = 0;
            try
            {
                DGV_Fac_SMS.ColumnCount = 4;
                sql = "Select S.Faculty_Code, (select F.Mobile_No from Tb_SCH_Faculty_Details F where F.Faculty_Code = S.Faculty_Code) as MobileNo from Tb_SCh_TIme_Table S group by S.Faculty_Code";
                oledr = GFun.ReadAcessSql(sql);
                while (oledr.Read())
                {
                    DGV_Fac_SMS.Rows.Add();
                    DGV_Fac_SMS[0, iRow].Value = oledr[0].ToString();
                    DGV_Fac_SMS[1, iRow].Value = oledr[1].ToString();
                  

sql = "Select [Sch_Date] & ',' & [Session] & ',' & [Course] as Message FROM Tb_SCH_TIme_Table  where [Faculty_Code] = '" + oledr[0].ToString() + "' ";
                    oledrmsg = GFun.ReadAcessSql(sql);
                    while (oledrmsg.Read())
                    {
       
          DGV_Fac_SMS[2, iRow].Value = DGV_Fac_SMS[2, iRow].Value + oledrmsg[0].ToString();
                    }
                   
                    iRow = iRow + 1;
                    oledrmsg.Close();
                }
                oledr.Close();
            }

            catch (Exception ex1)
            {
                MessageBox.Show(ex1.ToString(), "Error", MessageBoxButtons.OK);
                this.Cursor = Cursors.Arrow;
                return;
            }


when i run output as follows in datagridview;

Name     Mobile                  Message                            
AKR    97090578905   2/25/2013,1,REO2/26/2013,2,MFA   


But i want the the above output in datagridiview, the below one as follows;

Name     Mobile            Message
AKR    97090578905    2/25/2013,1,REO
                      2/26/2013,2,MFA


how can i get the above output.

in my code what changes i can made to get the output.

Please help me.

Note it is windows application.


[edit]Code blocks added[/edit]
Posted
Updated 1-Mar-13 23:27pm
v2
Comments
[no name] 2-Mar-13 6:09am    
please replay how can i do?

please send the answer for my above question.

1 solution

Hi,

can you try by changing your code in second while loop as below.
C#
DGV_Fac_SMS.Columns[2].DefaultCellStyle.WrapMode = DataGridViewTriState.True;
while (oledrmsg.Read())
{
    DGV_Fac_SMS[2, iRow].Value = DGV_Fac_SMS[2, iRow].Value + Envirnment.NewLine +  oledrmsg[0].ToString();
}


hope it works.
 
Share this answer
 
v2
Comments
[no name] 2-Mar-13 9:21am    
when i run output as follows in datagridview;

Name Mobile Message
AKR 97090578905 2/25/2013,1,REO2/26/2013,2,MFA

But i want the the above output in datagridiview, the below one as follows;

Name Mobile Message
AKR 97090578905 2/25/2013,1,REO
2/26/2013,2,MFA

i try your below code as follows;

while (oledrmsg.Read())
{
DGV_Fac_SMS[2, iRow].Value = DGV_Fac_SMS[2, iRow].Value + Envirnment.NewLine + oledrmsg[0].ToString();
}

But in datagridview is not changing?

why what is the problem.

i tried your code but it is not working.

Please help me.
note it is windows application.

Please help me.

regards,
Narasiman P.
Karthik Harve 2-Mar-13 10:36am    
try with my updated solution.
[no name] 3-Mar-13 8:28am    
i try u=your updated solution i my code but in run mode in datagridview is not changing why.

while (oledrmsg.Read()) { DGV_Fac_SMS[2, iRow].Value = DGV_Fac_SMS[2, iRow].Value + Envirnment.NewLine + oledrmsg[0].ToString(); }

i tried ur above code but it is not working
please help me.
Karthik Harve 4-Mar-13 0:24am    
did you set the wrap mode for a column ?

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