Searching a DataGrid

kertsman

Newcomer
Joined
Nov 12, 2003
Messages
5
Hello,

I was hoping someone would be able to help me with a problem. I have a form that contains a datagrid bound to a dataset, a textbox and a combobox that is filled with the grid's column names. I want to be able to select a column from the combobox and then type in the textbox. As I type, I want to search the specified grid column for the matching characters. Basically, I want to do something similar to a combobox lookup or autofill, only with a textbox and grid.

Is this even possible? If so, please help, this is for a project that is slightly overdue.

Thanks for your help!
 
It is very easily done...

In the change event of the search textbox use rowFilter of the Dataview of the Dataset to specify the Where clause, ie..

Visual Basic:
dv.RowFilter = myCombo.Text & " LIKE '" & myTextBox.text & "%'"

'You need to bind the Grid to the dataview instead of the Dataset
 
Thanks Robby, that will certainly do close to what I want, but do you know if there is a way to do it without filtering the results? Ideally, I still want the user to be able to scroll through the grid with the full dataset listed even if they do a search. Also, The column names I have in the ComboBox are not the actual column names of the table, the ComboBox are plain English instead of the abbreviated I used in the table. Hmmmm...

Thanks again, I will give your idea a try it maybe good enough for my boss.
 
I did the exact thing except instead of a combo I filtered on the last column or cell the user clicked on, eitherway works.

If you don't filter you can simply Find an item in the grid, take note on how you want to approach this, will you re-sort by the column they choose or....? You understand where I going with this?
 
Hm, yes I see what you are getting at. What I am doing is after the user selects the record, either through a manual search or hopefully soon a text find, they click a button and a new form open with data populated in the field based ona column from the grid.

So, I think the Find method might work, I just need to figure out the Find command for the Grid.
 
I am facing same problem

Hello,
I want solution for same problem, if you have solution pls help me.

kertsman said:
Hello,

I was hoping someone would be able to help me with a problem. I have a form that contains a datagrid bound to a dataset, a textbox and a combobox that is filled with the grid's column names. I want to be able to select a column from the combobox and then type in the textbox. As I type, I want to search the specified grid column for the matching characters. Basically, I want to do something similar to a combobox lookup or autofill, only with a textbox and grid.

Is this even possible? If so, please help, this is for a project that is slightly overdue.

Thanks for your help!
 
Are you basically wanting to scroll up or down to the first occurrance of the text you are searching?
Guha
 
Back
Top