|
-
Aug 28th, 2006, 08:03 PM
#1
Thread Starter
New Member
Triggering a routine in the parent form
Hi all! I've been having no luck at all the past few months triggering an event within my parent form, from my child form...
Allow me to elaborate...
I have a function that loads some dabase info into a list view:
Code:
public void photologload()
{
OleDbConnection Myconnection = null;
OleDbDataReader dbReader = null;
Myconnection = new OleDbConnection (@"Provider=Microsoft.Jet.OLEDB.4.0; User Id=; Password=; Data Source=ghostphotos.mdb");
Myconnection.Open();
OleDbCommand cmd = Myconnection.CreateCommand();
cmd.CommandText = "SELECT * FROM photos";
dbReader = cmd.ExecuteReader();
int ida;
while(dbReader.Read())
{
ida = (int)dbReader.GetValue(0);
nameofphoto = (string)dbReader.GetValue(1);
photodescription = (string)dbReader.GetValue(2);
pathtophoto = (string)dbReader.GetValue(3);
datetaken = (string)dbReader.GetValue(4);
photosummary = (string)dbReader.GetValue(5);
//populate the log box
ListViewItem lvItem = photoview.Items.Add(datetaken);
lvItem.Tag = ida;
lvItem.SubItems.Add(nameofphoto);
lvItem.SubItems.Add(photodescription);
}
dbReader.Close();
Myconnection.Close();
}
I then have a button on my form that allows me to add a new photo via a child form:
Code:
private void newphoto_Click(object sender, System.EventArgs e)
{
photoadd newphoto = new photoadd();
newphoto.Show();
}
What I want to do is, when I close the child form, I want the photoloadlog event to occur. I've tried passing variables, checking states of the child, etc, and nothign seems to get it to work correctly.
Any insight into this one would be greatly appreciated!!!
-
Aug 28th, 2006, 09:09 PM
#2
Re: Triggering a routine in the parent form
Do you want to be able to access the parent form while this child form is visible? If not then you should be calling ShowDialog rather than Show. ShowDialog blocks until the form is dismissed, so when ShowDialog retruns you know that the form has been dismissed and you can perfrom whatever action is required.
-
Aug 28th, 2006, 09:20 PM
#3
Thread Starter
New Member
Re: Triggering a routine in the parent form
Sir I bow to you! Thank you!
In all this time I have never even though of that!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|