Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Hi I have 2 Form Form1 and Form2

Form1 have a table and there is my records and there is a Void for refresh the table in the Form1.

Form2 is my insert form I am insertig data to sqlserver.I wantto that When after i save the record in Form2 to run Form1 Refresh void.(when Form1,Form2 opened)

thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
486 views
Welcome To Ask or Share your Answers For Others

1 Answer

Form2 will have to have a reference to the instance of Form1. You can pass this reference to Form2 when the insert button is clicked:

Form2 insertForm = new Form2();
//Form2.ShowDialog(Me); - Correction - 'Me' is for VB. in C# it's:
Form2.ShowDialog(this);

Next on Form2 you can access Form1 like this:

(Form1)this.Parent.RefreshTable();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...