Click here to Skip to main content
13,004,094 members (112,643 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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?


Posted 3-Jan-13 11:29am
Not clear. If a row is already selected, it is "highlighted". Or, do you mean something else by "highlighting"?

1 solution

Rate this: bad
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.
RickiB 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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100