0
這裏我有一個窗體,其中包含一個datagrid視圖和三個按鈕,即編輯,刪除和返回。 Internally當我加載窗體它顯示DataGrid中正確的數據,但假設如果我編輯或刪除記錄通過單擊編輯或刪除按鈕,當這種形式來到執行這些操作後,前景DataGrid視圖isn沒有顯示更新的數據。 任何幫助將受到歡迎..... 注 - 此表單不會關閉,當我點擊編輯或刪除按鈕,它只是進入後臺。 我的代碼如下: -如何更新從後臺到前臺的表單時的DataGrid視圖?
namespace RDASMS
{
public partial class LoginDb : Form
{
DataTable dt = new DataTable();
public LoginDb()
{
InitializeComponent();
}
//OleDbConnection vcon = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\workspace\RDASMS\RDASMS\rdadb.mdb");
public Form ReferToAdmin
{
get;
set;
}
private void LoginDb_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'rdadbDataSet1.login' table. You can move, or remove it, as needed.
// this.loginTableAdapter.Fill(this.rdadbDataSet1.login);
// TODO: This line of code loads data into the 'rdadbDataSet.login' table. You can move, or remove it, as needed.
//this.loginTableAdapter.Fill(this.rdadbDataSet.login);
MyOleDbConnection.Open();
DataSet ds = new DataSet();
//DataTable dt = new DataTable();
ds.Tables.Add(dt);
OleDbDataAdapter da = new OleDbDataAdapter();
da = new OleDbDataAdapter("select * from login", MyOleDbConnection.vcon);
/*da.Fill(dt);
logindb_dataGridView.DataSource = dt.DefaultView;*/
da.Fill(dt);
logindb_dataGridView.DataSource = dt;
logindb_dataGridView.AutoResizeColumns();
MyOleDbConnection.Close();
}
private void logindb_panel_Paint(object sender, PaintEventArgs e)
{
}
private void logindbback_Click(object sender, EventArgs e)
{
this.Close();
this.ReferToAdmin.Show();
}
private void logindbdelete_Click(object sender, EventArgs e)
{
DeleteRecord dr = new DeleteRecord();
dr.ReferToLogindb = this;
dr.Show();
this.Hide();
}
private void logindbedit_Click(object sender, EventArgs e)
{
EditRecord er = new EditRecord();
er.ReferToLogindb = this;
er.Show();
this.Hide();
}
}
}