Click here to Skip to main content
15,891,896 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to search particular product name in form1 datagridview the search depend on form2 textbox text write as per alphabetical & the both form parallel work.
some one help me



regards:

rahul
Posted
Comments
conniekigg 31-Oct-11 13:16pm    
sample codE?
Arun Kumar Ghadai 5-Nov-11 3:04am    
form1 shows on form2,form3,form4,form5 etc.single form shows on other form when required.

1 solution

This type of question: how to take some content from one Form and then act on it, or pass it to, or make it accessible to, another Form ... is one of the most frequent questions asked and answered here on CP QA.

The first question to ask, and answer is:

1. where are form1 and form2 created: by a third form ? does form1 create form2, or form2 create form1 ?

and ... think about what 'opportunities' you have to create a 'public reference' at whatever point in your code the Forms are created.

2. since either Form1 has to "know" and access the TextBox on Form2 ... or Form2 has to "know" and access the DataGridView on Form1:

Which makes more sense to you: to 'expose' the TextBox on Form2 to Form1 ... or to expose the DataGridView on Form1 to Form2 ... think about this: this is an important strategic design choice.

3. you need to answer the general question: what type of object can I create within the scope of a Form that can be accessed or "seen" from outside that Form's definition (hint: Public Property).

... but even if you have an object 'exposed' by a Public Property ... the other form (the outside object) is going to need a reference to an instance of the other object to access it (we are deliberately avoiding any mention of strategies involving 'static here).

4. and another strategy used often in this scenario is to answer the question: how can I make a Form, or an object on a Form, directly available within another Form (hint: injection).

good luck, Bill
 
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