I want to reaccess some of my child usercontrol from my main form..I want to access the object "watch" that i've declared from WatchListUC watch = new WatchListUC();
from my main I've declared this user control on a panel of the main form
private void MyList_Load(object sender, EventArgs e)
{
LogInScreen screen = new LogInScreen();
panel2.Controls.Clear();
panel2.Controls.Add(screen);
loadDB();
grid.ContextMenuStrip = OpenDetails;
}
then after that i created a login and there i was able to call the WatchListUC watch = new WatchListUC(); which i want to recall later
on the login screen here's the code
private void LogIn_Click(object sender, EventArgs e)
{
SuspendLayout();
try
{
MySqlConnection conn = new MySqlConnection(myConnection);
conn.Open();
MySqlCommand command = new MySqlCommand("SELECT * FROM maindatabase.users where user=?parameter1 and pass=?parameter2;", conn);
command.Parameters.AddWithValue("?parameter1", User.Text);
command.Parameters.AddWithValue("?parameter2", Pass.Text);
MySqlDataReader reader = command.ExecuteReader();
int ctr = 0;
while (reader.Read())
{
ctr++;
// controlnum = reader["idnum"].ToString();
MyList.AccountControlNum = int.Parse(reader["idnum"].ToString());
// MessageBox.Show(MyList.AccountControlNum.ToString());
}
if (ctr == 1)
{
this.Parent.Controls.Remove(this);
MyList my = MyList.ActiveForm as MyList;
UserAccount acc = new UserAccount();
my.panel2.Controls.Add(acc);
my.label1.Text = reader["user"].ToString()+" 'List";
WatchListUC watch = new WatchListUC();
my.panel3.Controls.Clear();
my.panel3.Controls.Add(watch);
FinishListUC finish = new FinishListUC();
my.panel4.Controls.Clear();
my.panel4.Controls.Add(finish);
// MessageBox.Show("Success!");
}
else
{
MessageBox.Show("Invalid Username or Password!");
}
conn.Close();
ResumeLayout();
}
catch (Exception ex)
{
MessageBox.Show("error" + ex);
ResumeLayout();
}
ResumeLayout();
}
now on my main form how I do I reaccess here after the "insertWL()" method??
void ConfirmedWL()
{
SuspendLayout();
try
{
MySqlConnection conn = new MySqlConnection(myConnection);
conn.Open();
MySqlCommand command = new MySqlCommand("SELECT * FROM maindatabase.watchlist where ControlNum=?CN and idnum=?ID;", conn);
command.Parameters.AddWithValue("?CN", int.Parse(a.ToString()));
command.Parameters.AddWithValue("?ID", MyList.AccountControlNum);
MySqlDataReader reader = command.ExecuteReader();
int ctr = 0;
while (reader.Read())
{
ctr++;
}
if (ctr == 1)
{
MessageBox.Show("Already Existed!");
}
else
{
insertWL();
//WatchListUC watch1 = panel3.Controls.Find("watch", true).DefaultIfEmpty() as WatchListUC;
//watch1.dvgRefresh();
//here i want to recall the watch so i can call the method dvgRefresh();
}
conn.Close();
ResumeLayout();
}
catch { }
}<br>
I was hoping someone could help me here's my full code and screen shots http://www.mediafire.com/download/1l18e6v8158mi16/Help_please.rar