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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:09:11+00:00 2026-06-11T12:09:11+00:00

I want that when I insert or update records in another form ( Form2

  • 0

I want that when I insert or update records in another form (Form2), the DataGridView on Form1 should automatically refresh (call btnRefresh) after each operation or preferably wait until all change operations have finished, and update the DataGridView form Form2‘s closing event with all changes.

I believe in VB.NET this is achieved with Form1.DataGridView.Refresh, but I am not sure in C#. I was told that I pass the reference of the DataGridView on Form1 to Form2 using properties but since I’m new to C#, I didn’t know how to. How can I resolve this issue?

My refresh button code:

private void btnRefresh_Click(object sender, EventArgs e)
{
    GVThesis.DataSource = thesisRepository.GetThesis();
    GVThesis.Refresh();
}
  • 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-11T12:09:12+00:00Added an answer on June 11, 2026 at 12:09 pm

    Firs, wrap your refresh code into a method of its own, and call that from your click event handler method, like so:

        private void btnRefresh_Click(object sender, EventArgs e) 
        { 
            this.RefreshData();
        }
    
        public void RefreshData()
        {
            GVThesis.DataSource = thesisRepository.GetThesis(); 
            GVThesis.Refresh(); 
        }
    

    Then, asuming you are instantiating and launching the new form (Form2) from your Form1, simply go into the code of Form2 and create yourself a new constructor overload which will accept a reference to Form1, and store it in a private variable, like so:

    public partial class Form2 : Form
    {
        private Form1 frm1;
    
        public Form2()
        {
            InitializeComponent();
        }
    
        public Form2(Form1 otherForm)
        {
            InitializeComponent();
            this.frm1 = otherForm;
        }
    }
    

    Then you can call the “refresh” from anywhere you like in Form2 like so:

    this.frm1.RefreshData();
    

    EDIT:

    I created a small sample, I cannot upload it here…but here is a screenshot of both the program itself in VS, as well as a screenshot of the result of running it and performing the function…hopefully that will help.

    The program (zoom your view if it appears too small)
    The Program in VS 2010

    The Result:
    A function on Form1, called from Form2

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

Sidebar

Related Questions

so the problem is, that i want to insert a new row after another
Sometimes if I want to quickly copy records from one table to another (that
I want to insert or update, then insert a new log into another table.
I want to create a site in PHP with cakephp that users can insert
I've got an after insert trigger that works well. However, I want it to
i want to insert all processes that running into listbox, and also how to
I want to insert into my table a column named 'S' that will get
I want to have an insert tab button for my UITextView so that users
I want to insert tags in new Place. giving that tags is in different
I have a test file that contains 1,2,3 2,3,4 5,6,7 I want to insert

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.