|
Filter results of windowsform.DataGrid control -- rhaazy --
I have a datagrid that is populated based on what node of a treeview the user selects. So there are multiple times in the code where I call the datagrid.datasource = source method. each time this gets called a new dataset is created and filled with a query adapter. I can't quite figure out how to use a textbox's TextChanged event to create a search method to filter the datagrid. Any help would be appreciated using C# VS2003 |
|
-- rhaazy --
I figured out how to do the search, but I can't put it in the TextChange event because it only filters if the strings are equal, I need it to do it if its 'like' the string... DataSet ds = (DataSet)dataGrid1.DataSource; DataView dtView = ds.Tables .DefaultView; dtView.RowFilter = "AssetName" + " = '" + textBox1.Text +"'" ; dataGrid1.DataSource = dtView; dataGrid1.Refresh(); Anyone know how i can change this to filter as I am typing. I also am concerned if its gonna work at all the right way because of how the code is strucutred, it seems to me that by assigning the datasource as the dataview when it loops thorugh again its just going to keep the previous dataview as the source, which is fine until the user decides they dont want to search... |