Filter a Record "Partial key search"
-
:-D Good Morning, i have a problem! i have a form with a TextBox and DataGrid. i fill a DataGrid with DataBase records and when i select a record in DataGrid i show it in textbox! But i want to type a character at textbox and automatically locate the record in DataGrid (Partial key search)! Thanks a lot!
-
:-D Good Morning, i have a problem! i have a form with a TextBox and DataGrid. i fill a DataGrid with DataBase records and when i select a record in DataGrid i show it in textbox! But i want to type a character at textbox and automatically locate the record in DataGrid (Partial key search)! Thanks a lot!
Hello, you can use a Filter on the Datagrid: At first, you must create a DataView on your table. DataView dv = new DataView(); dv.Table = MyDataSet.Tables["Suppliers"]; Then you can set the RowFilter like this : dv.RowFilter = "City = 'Berlin'"; You can use different FilterOptions, like in SQL : dv.RowFilter = "Name = 'S%'"; S% -> All that begans with S ( Naturally it seems in you case like this : dv.RowFilter = "Name = '" + textbox.Text + "%'"; Then you choose the DataView as DataSource of the Grid There are propably some errors im my example, but the logic is right ( I used it before 1 year and i still don't have the code here ) Good luck
-
Hello, you can use a Filter on the Datagrid: At first, you must create a DataView on your table. DataView dv = new DataView(); dv.Table = MyDataSet.Tables["Suppliers"]; Then you can set the RowFilter like this : dv.RowFilter = "City = 'Berlin'"; You can use different FilterOptions, like in SQL : dv.RowFilter = "Name = 'S%'"; S% -> All that begans with S ( Naturally it seems in you case like this : dv.RowFilter = "Name = '" + textbox.Text + "%'"; Then you choose the DataView as DataSource of the Grid There are propably some errors im my example, but the logic is right ( I used it before 1 year and i still don't have the code here ) Good luck
thanks dude!! i'll try it "Filter on the DataGrid"!! if i find out anything else i´ll call you again!!! cya!