本文介绍了强制填充DataGrideView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我正在Window窗体应用程序上工作,正在使用"DataGrideView"控件.它具有tabcontrol,并且我的两个标签都包含2个不同的"DataGrideView",我使用下面的代码在第一个标签及其上填充"DataGrideView"工作绝对好:

Hello All,
Am working on the Window form application and I am using "DataGrideView" Control On that.I have tabcontrols on that and my both the tab consist 2 diffrerent "DataGrideView" I use the code below to fill "DataGrideView" on my first tab and its working absolutly fine:

 con.Open();
OleDbCommand cmdcop = new OleDbCommand("Select * from Rechcop", con);
if (cmdcop.ExecuteReader().HasRows)
{
    OleDbDataAdapter adpcop = new OleDbDataAdapter("Select * from Rechcop", con);
    DataTable dtcop = new DataTable();
    adpcop.Fill(dtcop);
    grdRich.DataSource = dtcop;
    con.Close();
}
else
{
    MessageBox.Show("No Recharg Coupan is added yet.Add RechargeCoupan.");
    tabControl1.Focus();
}


但是,当我想用​​相同的方法在第二个选项卡上填充DataGrideView,但datagridview不同时,下面的代码将执行,但DataGridview仍然为空.


But when I want to fill DataGrideView on second tab with same method but datagridview is different the code below is executes but still DataGridview is Empty.

con.Open();
OleDbCommand cmdsim = new OleDbCommand("Select * from SimCard", con);
if (cmd.ExecuteReader().HasRows)
{
    OleDbDataAdapter adpsim = new OleDbDataAdapter("Select * from SimCard", con);
    DataTable dtsim = new DataTable();
    adpsim.Fill(dtsim);
    grdSimCard.DataSource = dtsim;
    con.Close();
}
else
{
    MessageBox.Show("No SimCard is added yet.Add SimCard.");
    tabControl1.Focus();
}



我尝试引用DataGride,但是它无法正常工作,我也尝试在ButtonClick上填充它,但仍然没有帮助.

有人可以帮我解决这个问题吗?...

在此先感谢
Yogesh
:-)



I tried to refersh the DataGride but it wont work,also I try to populate that on ButtonClick enevt still it wont help.

Can sombody Help me to tackle that issue....?

Thanks in Advance
Yogesh
:-)

推荐答案


这篇关于强制填充DataGrideView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 14:03