Click here to Skip to main content
15,879,613 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a form, form1, that displays a some data from a SQL table in a data grid view. In a menu tool strip on form1 the user can issue a command that starts form2. From form2 the user enter search criteria on a column in the data grid view. I would like form2 to to execute the same code as form1 to display the data grid view. How do I accomplish this?

What I have tried:

I have not tried anything yet.
Posted
Updated 24-Feb-18 10:30am

The best way may sound complicated, but it isn't, not really.
Create a new control derived from DataGridView (add a UserControl to your project, then change what it derives from to DataGridView) and add the code to that.
Then use the new control in both Form1 and Form2.
 
Share this answer
 
The number of forms is not important! All what you need to do is to use custom logic to get all filters from Form2. If user click [Accept] button then Form1 will display filtered data.

See:
Create a Windows Form to search data[^]
Pass data between forms[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900