• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

.NET DataGridView problem

SoftwareEng

Senior member
Hi guys,

I have a DataGridView in .NET 2.0 with some data. How can I make it automatically highlight the appropriate row when the user types the first letter of that row? You know, the way you type in any other list control to select the item.

thanks!
 
Umm don't think there is an easy way to do this. A Gridview is more or less a table. Perhaps with some client side finagling (likely using AJAX) you can have a textbox where the user types and based on that typing it would highlight the appropriate gridview row.
 
Originally posted by: rsd
Perhaps with some client side finagling (likely using AJAX) you can have a textbox where the user types and based on that typing it would highlight the appropriate gridview row.
I don't see the word asp anywhere in his post.

Anyway, assuming this is winforms, is there a convenient keypress handler you can implement, then search the rows and manually highlight the correct one?
 
This isn't Web-related; it's a regular Windows app. Doing this manually is painful because as the user continues typing, the correct item should be selected. I want it to act similarly to Windows Explorer where typing a file or folder name will select the matching item in the list (e.g. type Windows while viewing your C:\ drive).

Any new suggestions?

thanks again
 
So keep a string of all the keys the user has pressed and record the time that the last one was pressed. If the time is sufficiently short, just append the new character. If it's too long, clear the string and start with just the new character.
 
Originally posted by: kamper
Originally posted by: rsd
Perhaps with some client side finagling (likely using AJAX) you can have a textbox where the user types and based on that typing it would highlight the appropriate gridview row.
I don't see the word asp anywhere in his post.

Anyway, assuming this is winforms, is there a convenient keypress handler you can implement, then search the rows and manually highlight the correct one?

Sorry my bad!
 
Originally posted by: kamper
So keep a string of all the keys the user has pressed and record the time that the last one was pressed. If the time is sufficiently short, just append the new character. If it's too long, clear the string and start with just the new character.

I may have to do that... but see, mouse clicks and other events should reset the typed string. maybe for the version 2.0

thanks
 
Ideally, but what do you think your timeout will be? I'd guess 1 second, maybe 2. Unless you're typing with one hand and have the other on the mouse, switching between kb and mouse will probably reset the string just by how long they take.
 
Back
Top