Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
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
Posted 3-Jan-13 11:29am
RickiB649
Comments
Sergey Alexandrovich Kryukov at 3-Jan-13 18:29pm
   
Not clear. If a row is already selected, it is "highlighted". Or, do you mean something else by "highlighting"?
—SA

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
RickiB at 3-Jan-13 18:54pm
   
Thanks rahkan, that's the ticket! I still must be in vacation mode...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web03 | 2.8.140709.1 | Last Updated 3 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid