I'm a fill datagridview When it opens the second form the value displayed will not
Why?
My code:
// in form1
private bool Method1()
{
using (var form2 = new frmMain())
{
form2.RaiseLoadEvent(EventArgs.Empty);
}
return (true);
}
private void frm1_Load(object sender, EventArgs e)
{
Method1();
this.DialogResult = DialogResult.Cancel;
}
// in form2
public void RaiseLoadEvent(EventArgs e)
{
this.OnLoad(e);
}
private void OnLoad(EventArgs e)
{
this.con = new OleDbConnection(this.ConnectionString());
string strquery = "select * from english";
this.dba = new OleDbDataAdapter(strquery, con);
this.dba.Fill(this.ds);
this.dataGridView1.DataSource = this.ds.Tables[0].DefaultView;
}
code in Program.cs :
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
frm1 frmsp = new frm1();
if (frmsp.ShowDialog() == DialogResult.Cancel)
{
Application.Run(new frmMain());
}
}