通过form2文本框文本在form1 datagridview中搜索 [英] Search in form1 datagridview through form2 textbox text

查看:70
本文介绍了通过form2文本框文本在form1 datagridview中搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在form1 datagridview中搜索特定的产品名称,搜索取决于按字母顺序写的form2文本框文本和两者的并行工作. 有人帮我



问候:

rahul

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

推荐答案

此类问题:如何从一个Form中获取某些内容然后对其执行操作,或将其传递给另一Form或使其可访问...是CP质量检查中最常问和回答的问题之一.

要问的第一个问题,答案是:

1. form1和form2在哪里创建?:由第三种形式生成? form1是创建form2还是form2创建form1?

然后...考虑在创建表单的代码的任何点创建公共引用"所需要的机会".

2.因为Form1必须知道"并访问Form2上的文本框...或Form2必须知道"并访问Form1上的DataGridView:

这对您更有意义:将Form2上的文本框公开"到Form1 ...或将Form1上的DataGridView公开给Form2 ...考虑一下:这是一项重要的战略设计选择.

3.您需要回答以下一般性问题:在可以从该窗体定义之外访问或看到"的窗体范围内,我可以创建哪种类型的对象(提示:公共属性).

...但是即使您有一个对象由公共财产"公开" ...另一种形式(外部对象)也需要对另一对象实例的引用访问它(我们故意避免提及涉及此处为静态"的策略).

4.在这种情况下,经常使用的另一种策略是回答这个问题:如何在另一个表单(提示:注入)内直接在一个表单中直接创建一个表单或表单上的对象. />
Bill,祝你好运
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


这篇关于通过form2文本框文本在form1 datagridview中搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆