-2

I have developed a program which save, delete, update, search and the records are displayed on one form(MainForm1). The help I need is to have another form(SearchForm) whereby I can use it for searching only but the information should be displayed on the main form(MainForm1) when I search. 

MainForm1- save, delete, update( the records should be displayed here when searching).

SearchForm- searching only here

I have no idea how can i do it.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Marcus
  • 47
  • 2
  • 12
  • Make sure the SearchForm has a reference to the MainForm1. Make public methods on MainForm1 that SearchForm can use to display the result. – Wolf5 Jun 29 '15 at 23:59
  • 1
    Simply listing your requirements and asking for help is not a good way to ask a question on this site. Please see [Why is "Can someone Help me" not an "actual" question](http://meta.stackoverflow.com/questions/284236/why-is-can-someone-help-me-not-an-actual-question). Show us how _you_ tried to solve the problem yourself, then show us _exactly_ what the result was, and tell us why you feel it didn't work. – John Saunders Jun 29 '15 at 23:59
  • 1
    possible duplicate of [Passing Values Between Windows Forms](http://stackoverflow.com/questions/17836398/). – Dour High Arch Jun 30 '15 at 00:03

1 Answers1

0

Create your new form as usual and put your MainForm in the constructor like this:

public class SearchForm : Form {
    MainForm m;

    public SearchForm(MainForm _m) {
        InitializeComponent();
        m =_m;
    } 
} 

Call the new class/form using new SearchForm(this).Show(); from your MainForm class.

Now set the modifiers of the controls you want to update to public, so you can access them from your SearchForm class using something like m.TextBox1.Text = "Hello world!.

DerAtrox
  • 183
  • 10