legd1991 Posted December 8, 2009 at 03:14 PM Report Share #299267 Posted December 8, 2009 at 03:14 PM boas pessoal... como faço para pesquisar numa datagridview o valor de uma textbox explico melhor: quero que a medida que escrevo na textbox me filtrasse a datagridview e m mostrasse apenas as linhas que na coluna 1 começam pelas letras que estao na textbox... cumps legd1991 Link to comment Share on other sites More sharing options...
bruno1234 Posted December 8, 2009 at 03:25 PM Report Share #299269 Posted December 8, 2009 at 03:25 PM Para isso tens q por o evento TextChanged da textbox a obter a palavra q introduziste. Com essa palavra filtras os teus dados e afectas novamente o datasource da gridview (Aqui usar linq facilita mto a vida). Isso deve ser o suficiente para o q queres. Matraquilhos para Android. Gratuito na Play Store. https://play.google.com/store/apps/details?id=pt.bca.matraquilhos Link to comment Share on other sites More sharing options...
legd1991 Posted December 8, 2009 at 05:44 PM Author Report Share #299300 Posted December 8, 2009 at 05:44 PM obrigado pela ajuda.. ja agora como faço para que ao inserir "An" por exemplo me apareçam na datagrid view todos os nomes que começem por "An"? Link to comment Share on other sites More sharing options...
bruno1234 Posted December 8, 2009 at 05:52 PM Report Share #299305 Posted December 8, 2009 at 05:52 PM Tens q filtrar os dados com q depois vais afectar a gridview. Se usares linq é mais fácil, é só filtrares por startswith "An". Se for uma lista ou um array tens q fazer um ciclo e filtrar um a um. Matraquilhos para Android. Gratuito na Play Store. https://play.google.com/store/apps/details?id=pt.bca.matraquilhos Link to comment Share on other sites More sharing options...
legd1991 Posted December 8, 2009 at 06:13 PM Author Report Share #299309 Posted December 8, 2009 at 06:13 PM podes so explicar como faço essa parte do startswish?? eu tenho assim: Dim texto As String = Nothing If TextBox1.Text <> String.Empty Then For Each linha As DataGridViewRow In EmpresasDataGridView.Rows For Each celula As DataGridViewCell In EmpresasDataGridView.Rows(linha.Index).Cells If celula.ColumnIndex = 1 Then texto = UCase(celula.Value.ToString) 'se o texto informado estiver contido na célula então seleciona toda linha If texto = UCase(TextBox1.Text) Then 'seleciona a linha EmpresasDataGridView.CurrentCell = celula Exit Sub End If End If Next Next End If Link to comment Share on other sites More sharing options...
legd1991 Posted December 8, 2009 at 06:32 PM Author Report Share #299315 Posted December 8, 2009 at 06:32 PM ja consegui obrigado pela a ajuda Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now