在datagridview数据中以行方式显示 [英] in datagridview data to be displayed in row wise

查看:66
本文介绍了在datagridview数据中以行方式显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注意它是windows应用程序



代码如下表格加载,





Note it is windows application

Code as follows in the form load,


          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;
            }





当我在datagridview中按如下方式运行输出时;





when i run output as follows in datagridview;

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





但我想在datagridiview中输出以上内容,如下所示;





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





我怎样才能得到上面的输出。



在我的代码中我可以做出哪些改变来获得输出。



请帮帮我。



注意它是windows应用程序。





添加的代码块[/ edit]

推荐答案





您可以尝试在第二个while循环中更改您的代码低。

Hi,

can you try by changing your code in second while loop as below.
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.


这篇关于在datagridview数据中以行方式显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆