Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8235457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:49:05+00:00 2026-06-07T18:49:05+00:00

Scenario: A child form which is made visible via a button. A delegate is

  • 0

Scenario:

  • A child form which is made visible via a button.
  • A delegate is created to run certain code when this child is closed.
  • The child form is used to edit the underlying data
  • When the child form is closed the latest version of the data should be displayed on any bound controls on the parent form.

Question –

Here is the relevant code attempt:

public partial class uxRevisionHelperForm : Form
{

    public SqlCeConnection conn = new SqlCeConnection(ConfigurationManager.ConnectionStrings["WindFormAppRevisionHelper.Properties.Settings.DefinitionsDBConnectionString"].ConnectionString);
    BindingSource definitionsBindingSource = new BindingSource();

    public uxRevisionHelperForm()
    {
        InitializeComponent();
        uxDescriptionTextBox.AutoSize = true;
        refreshBindingSource();
        assignControlsToSource();
    }

      //>>>>>>>>ALL OF THE FOLLOWING METHOD IS CALLED BY THE DELEGATE WHEN THE CHILD IS CLOSED
    public void refreshBindingSource()
    {            

        SqlCeDataAdapter da = new SqlCeDataAdapter(new SqlCeCommand("Select * From tb_RevisionDefinitions",conn));
        DataSet ds = new DataSet("Helper");
        ds.Tables.Add("DefinitionsTable");
        da.Fill(ds.Tables["DefinitionsTable"]);

        // Assign the BindingSource.
        definitionsBindingSource.DataSource = ds.Tables["DefinitionsTable"];
        uxBindingNavigator.BindingSource = this.definitionsBindingSource;

    }
    void assignControlsToSource() 
    {
        uxDescriptionTextBox.DataBindings.Add(new Binding("Text", definitionsBindingSource, "Description", true));
        uxWordPhraseTextBox.DataBindings.Add(new Binding("Text", definitionsBindingSource, "WordPhrase", true));
        uxReferenceTextBox.DataBindings.Add(new Binding("Text", definitionsBindingSource, "Reference", true));
    }

    private void uxUpdateDataButton_Click(object sender, EventArgs e)   
    {
        uxRevisionHelperGroupBox.Enabled = false;
        uxBindingNavigator.Hide();
        uxFormDatabase myNewDisplay = new uxFormDatabase();
        myNewDisplay.FormClosed += delegate { activateGroupBorder(); };
        myNewDisplay.Show();    
    }

    public void activateGroupBorder() 
    {
        uxRevisionHelperGroupBox.Enabled = true;
        uxBindingNavigator.Show();
        refreshBindingSource();    //<<<<<<<<<<<DELEGATE CALLS THIS METHOD
    }

}

The above seems to work but do I really have to run all the code in the method refreshBindingSource to make sure the info displayed on the parent form is up-to-date ?

UPDATE

I’ve followed Amiram’s advice and passed in my BindingSource so as not to have to repeat code already in place for the parent form. I’ve copied in some boiler plate code the method saveToolStripButton_Click; … really don’t know what is going on in that small routine – will those two lines will suffice for saving info back to the database?

public partial class uxFormDatabase : Form
{

    BindingSource rawtableBindingSource = null;

    public uxFormDatabase(BindingSource myPassedSource) 
    {
        InitializeComponent();
        rawtableBindingSource = myPassedSource;

        uxDGVtable.AutoSize = true;
        uxDGVtable.SizeChanged += new EventHandler(uxDGVtable_change);
        dataToDGV();
    }
    public void uxDGVtable_change(object sender, EventArgs e)
    {
        if (uxDGVtable.Width < 1158)
        {
            this.Width = uxDGVtable.Width;
        }
    }

    public void dataToDGV()
    {
        uxrawdataBindingNavigator.BindingSource = this.rawtableBindingSource;
        uxDGVtable.DataSource = this.rawtableBindingSource;
    }

    private void saveToolStripButton_Click(object sender, EventArgs e)
    {
        Validate();
        rawtableBindingSource.EndEdit();
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T18:49:07+00:00Added an answer on June 7, 2026 at 6:49 pm

    If you used different data source for both forms them you have no choice but to reload data (there is a way to automate that with sql server), but you can avoid that if you’ll use the same dataset or even the same BindingSource, so the refresh will happen automatically.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a scenario where i created pipe for communication between two child and
I have implement a scenario which involves two way communication between child and parent
I have a scenario in which DP Inheritance is not working, my code can
I have a scenario. (Windows Forms, C#, .NET) There is a main form which
Scenario: old legacy code in rpg have to consume data from a new web
Scenario : There is this online questionaire that will be filled in by various
Scenario 1: I have one wrapper Perl script which uses another Perl module and
I have a scenario in which I need a self reference property as follow:
This is the scenario: 2 Entities: tree and another tree id idParent someValue 1
Scenario: I have an application (C#) that expects a SQL database and login, which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.