当前位置:编程学习 > C#/ASP.NET >>

[DataGridView]数据查找


 
  查找全部列的某个cell值,查找指定列的某个cell值,向前查找,向后查找。
  类似.net里面的F3搜索功能。
  找到之后高亮显示(只是这个cell)
  
  快速实现,如何是好?
--------------------编程问答-------------------- 你应当对DataGridView的数据源进行查找,在找到后确定了第几行第几列就可以用如下的方法把当前的单元格设置好:

this.dataGridView1.CurrentCell = this.dataGridView1[row, col]; --------------------编程问答-------------------- 怎么找,我的数据源是dataset。select?这个只能返回一组纪录集 --------------------编程问答-------------------- 顶
--------------------编程问答-------------------- bindingsource bind =new bindingsource();
bind.datasource=dataset.tables[0]
 bind.Sort = "" + 你要查找的字段+ "";
            string strS = this.txtSearch.Text.Trim();
            int foundIndex = bind.Find(strSearch, strS);
            if (foundIndex > -1)
            {
                bind.Position = foundIndex;
            }
            else
            {
                MessageBox.Show("没有找到数据!");
            }

==================================
试一下这个可不可以?
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,