在网格视图中搜索值 [英] search value in grid view

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

问题描述

你好。



需要帮助。

im做一个Windows应用程序,我需要在网格视图中搜索文本框中的值点击搜索按钮后。

必须选择包含搜索值的行。如果有可能请帮帮我。





有一个按钮,一个文本框和一个网格视图。

现在表单加载我正在从数据库中检索记录。

现在我想通过在文本框中给出他的消费者ID来搜索消费者的详细信息。

现在我的要求是点击搜索按钮后我需要突出显示包含此值的行。

请给出解决方案或给出任何有用的链接。



谢谢



问候

prajucta

hello.

need a help.
i m doing a windows application where i need to search a value from text box in grid view after search button click.
the row containing the search value must b selected. if it is possible then please help me.


there is one button one text box and one grid view.
now in form load i am retrieving records from database.
now i want to search details of a consumer by giving his consumer id in text box.
now my requirement is after clicking search button i need the row containing this value should be highlighted.
please give solution or give any useful link.

thanks

regards
prajucta

推荐答案

这应该对你有帮助。< br $> b $ b

C#中DataGridView中的搜索行 [ ^ ]



问候..
This should help you.

Search Row in DataGridView in C#[^]

Regards..


如果你想从gridview下面的文本框中获取值

这可以帮到你。



If you Want Values from textbox which under the gridview
May this will help you.

Textbox tex= gridview1.findcontrol("your textbox name") as textbox;
string value=tex.text;


Here Is Fully Working Codes.
where gvDetail is name of Grid view. 
On Search Button Click Write The Codes. 

searchString = textBox1.Text.Trim(); 
if (searchString == string.Empty || searchString.Length < 8)
  {
     MessageBox.Show("Enter Valid Consumer Number..!");
  }
  else
   {
     foreach (DataGridViewRow row in gvDetail.Rows)
   {                              if(row.Cells["SERVICENO"].Value.ToString().Contains(searchString))
    {
      gvDetail.CurrentRow.Selected = false;
      gvDetail.Rows[row.Index].Selected = true;
      int index = row.Index;
      gvDetail.FirstDisplayedScrollingRowIndex = index;
      break;
    }
  }
}


这篇关于在网格视图中搜索值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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