将突出显示移动到Filter上的DataGridView中的选定行 [英] Move Highlight to selected row in DataGridView on Filter

查看:75
本文介绍了将突出显示移动到Filter上的DataGridView中的选定行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个包含多个搜索/编辑文本框字段和一个DataGridView的表单。当用户键入搜索文本框字段时,它会使用DataGridView.Filter属性创建一个动态过滤器。



当用户双击DataGridView行时,它会填充在所有编辑文本框中,可能会更改过滤器。 DataGridView突出显示保持在相同的索引位置,但行已移动。



当应用滤镜时,如何让精彩集锦留在选定的行上?



谢谢,



Rick

Hi,
I have a Form that contains several search/edit textbox fields and a DataGridView. As the users type into the search textbox fields, it creates a dynamic filter using DataGridView.Filter property.

When the user double-clicks on the DataGridView row, it fills in all of the edit textboxes, which may change the filter. The DataGridView Highlight remains at the same indexed position, but the row has moved.

How can I get the Highlight to stay on the selected row when the filter is applied?

Thanks,

Rick

推荐答案

你需要获取id / key的值对于过滤前的行,然后将所选索引更改为过滤后该键所在的新行的索引,或者只是将所选索引重置为0并且在过滤后没有选择任何行。
You''d need to get the value of the id/key for the row before filtering and then change the selected index to the index of the new row that the key is located in after filtering, or just reset the selected index to 0 and have no rows selected after filtering.


这篇关于将突出显示移动到Filter上的DataGridView中的选定行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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