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 7757391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:04:56+00:00 2026-06-01T13:04:56+00:00

I have an application that shows data from a MySQL table. Basically, my application

  • 0

I have an application that shows data from a MySQL table. Basically, my application consists of two forms: the main form, and a form for adding stuff to the database.

The main form shows all the entries in the database and relevant information. When the user wants to add a new entry to the database, a secondary form is opened that prompts for information. Once the information is filled out, the user presses a Submit button and the form closes. My problem is that when the secondary form closes, the listBox in the main form doesn’t update to reflect the newly-added entry.

Here is the code that is executed when the user submits the secondary form:

    private void closeWindow()
    {
        mainForm parent = new mainForm();
        parent.listParts.Refresh();
        this.Close();
    }

Is there a reason when I call the listBox to be refreshed, it doesn’t show my newly-added information? Perhaps I am calling something in the wrong order? Or does the Refresh() method not even work like that?

Any help would be appreciated! Alternatively, if you know of a better way to do this, I’d love to hear it!

  • 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-01T13:04:57+00:00Added an answer on June 1, 2026 at 1:04 pm

    The problem is that you’re refreshing the wrong form:

    private void closeWindow()
    {
        mainForm parent = new mainForm();
        parent.listParts.Refresh();
        this.Close();
    }
    

    Since you use: new mainForm(), you’re allocating a completely separate instance of the “mainForm”, and refreshing it’s content. This will not effect the existing, opened form.

    I would recommend passing a reference to the mainForm to the constructor of the secondary form. It then would know which instance of mainForm it needs to use to call Refresh().

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

Sidebar

Related Questions

I have an application that shows some data in p:DataTable.... This table is accessible
I have a windows forms application that shows data in a grid view. The
I have an application that loads data from a .csv file and shows it
I have a script that grabs data from a MySQL database table and creates
Suppose you have an application that consists of two layers: A: A data layer
We have a win application that shows a web form in a web browser.
I have C# application that fills a GridView with data from a DataTable object,
I have an application that shows a list of items. The user can click
I have a simple HTML (as HTA) application that shows strange behavior on Windows
I have an application that currently stores timestamps in MySQL DATETIME and TIMESTAMP values.

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.