我获取以下问题. [英] I fetch following problem.

查看:62
本文介绍了我获取以下问题.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的问题中,我有一个 datagridview .其中包含所有员工记录.
现在,当我那时在文本框中键入employee Name时,我想将焦点更改为 dataGirdView ,并且在DataGirdView选中的行将与我相关,在中键入Employee Name文本框. .我想在C#Window应用程序中添加此功能.如果可能的话,请帮帮我.

In my problem I have one datagridview.it contain all employee record.
now when I type employee Name in textbox at that time i want to change focus to dataGirdView and in DataGirdView slected Row will be related to I have type Employee Name in textbox. .I want add this functionality in C# Window application .if possible any way then help me.

推荐答案

处理TextBox.TextChanged事件,或提供按钮进行搜索.
然后,在带有循环的DataGridView中找到适当的文本,然后选择它.
Handle the TextBox.TextChanged event, or provide a button to do the search.
Then, find the appropriate text in your DataGridView with a loop, and select it.
string s = myTextBox.Text;
foreach (DataGridViewRow dgvRow in mtDataGridView.Rows)
    {
    string cell = dgvRow.Cells["myColumnName"].FormattedValue.ToString();
    if (cell.StartsWith(s, true, CultureInfo.InvariantCulture))
        {
        dgvRow.Selected = true;
        break;
        }
    }

或者,如果您有很多行,则可以根据数据表设置DataView,然后将RowFilter更改为仅显示匹配的行.

Alternatively, if you have a lot of rows, you could set up a DataView based on your data table, and change the RowFilter to just display matching rows.


您好,
您可以使用文本框Textchanged事件,然后将焦点设置在Gridview上,并与
这样的查询重新绑定
Hi,
you can use textbox Textchanged event and on that u set focus on Gridview plus Rebind it with query like

Select * from emp where empname like ''%"=txtbox.text"%''


这篇关于我获取以下问题.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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