search button for vb 2010 ultimate in access 2007 database and filtering on a datagrid
Hi all!
I create a wpf file and I am trying to make a search button which filters a datagrid. First of all, I have a tab and on this tab a have a datagrid (dgr1). When I load this tab, I fill in a dataset from the database using a data adapter and this code:
DAProjects.Fill(DSProjects.Tables("Projects"))
and then I send and display the data set to the datagrid with this code:
dgr1.DataContext = DSProjects.Tables("Projects")
Also, I have a TextBox1 and PushButton and when i Push the button I want to diplay on my datagrid only the rows which have the text that I wrote in the textbox.
I try to do this using this code but I don't know how to display (filter) only some rows from the datagrid:
Dim pro As String
Dim MaxProjects As Integer
Dim counterpro As Integer = 0
Dim asd As Integer = -1
MaxProjects = DSProjects.Tables("Projects").Rows.Count
While counterpro < MaxProjects + 1 Or asd = -1
pro = DSProjects.Tables("Projects").Rows(counterpro).Item(1)
asd = pro.IndexOf(TextBox1.Text)
counterpro=counterpro+1
End While
Please explain to me your answer and your code because I don't have so much experience with databases and vb.
Thanx in advance!!!
sotos