C# Datagrid Search
-
Hi everyone.... Can anyone tell me if its possible to autosearch a datagrid if the user starts typing on it ? For example if the user starts typing in a Code field, the datagrid must go to the first location equal to the character pressed etc. until a code is found. Keypressed property ?? Please need help ! :((
-
Hi everyone.... Can anyone tell me if its possible to autosearch a datagrid if the user starts typing on it ? For example if the user starts typing in a Code field, the datagrid must go to the first location equal to the character pressed etc. until a code is found. Keypressed property ?? Please need help ! :((
Are you talking about a winform or asp.net app? If it's winform, you should be able to subscribe to the keydown (or keyup) event. Look at the args to the event and then set the selected index in your grid to whatever row (and whatever column in the row you're talking about) matches the key. If it's asp.net, you could hook up a javascript function and try to perhaps set a background color on one of the rows. But that will be quite difficult as you will have to interogate the generated table's cell values (innertext i think) and then set a background color on the row with the matching value. Another way to go might be to put a text box up above the grid and a button beside it that says something like 'find'. Let them type a text fragment into the box and then use the button's event to search the grid contents.
-
Are you talking about a winform or asp.net app? If it's winform, you should be able to subscribe to the keydown (or keyup) event. Look at the args to the event and then set the selected index in your grid to whatever row (and whatever column in the row you're talking about) matches the key. If it's asp.net, you could hook up a javascript function and try to perhaps set a background color on one of the rows. But that will be quite difficult as you will have to interogate the generated table's cell values (innertext i think) and then set a background color on the row with the matching value. Another way to go might be to put a text box up above the grid and a button beside it that says something like 'find'. Let them type a text fragment into the box and then use the button's event to search the grid contents.
Yes im talking about a windows form. I did the textbox and button thing but i want as less buttons as possible. Im trying the keydown event ... but having some trouble with it. The datagrid wants to refresh and get the data from the dataset again but i just want it to scroll down to the letter, letters or word ...
-
Hi everyone.... Can anyone tell me if its possible to autosearch a datagrid if the user starts typing on it ? For example if the user starts typing in a Code field, the datagrid must go to the first location equal to the character pressed etc. until a code is found. Keypressed property ?? Please need help ! :((
-