Closing a form

G

Guest

I have a windows form (a). On the form there is a search button that causes
another windows form (b) with a datagrid used to display the retrived data
from the SQL database. I would like to close form (a & b) when I select the
requested record. And reopen form (a) and display the selected record. I have
tried 'Owner.Close():'. The code thats used to call the search form (b)
follows:

private void btFind_Click(object sender, System.EventArgs e)
{
oclose = 1; // setup to do a close after the search is complete.
SearchOwner dddd = new SearchOwner(txtSearch.Text);
dddd.Show();
txtSearch.Text = string.Empty; // Clear the search field
}

Can someone give me some help thanks.
 
G

Guest

Instead of all that, I would do it like this:

On form A in the search button click eventhandler, hide form A, then call
form b using ShowDialog. On form b, create a public property called
SelectedRecord that you set when the user selects a record. Then when form b
returns control to form A, just check the SelectedRecord property of form B,
retrieve the record, and show form A again.

This isn't everything, but it should get you going in the right direction.

Tony
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top