USUÁRIO:      SENHA:        SALVAR LOGIN ?    Adicione o VBWEB na sua lista de favoritos   Fale conosco 

 

  Fórum

  Visual Basic .Net
Voltar
Autor Assunto:  Pesquisa datagrid usando banco.mdb vb.net
AABernardi
TANGARÁ
SC - BRASIL
ENUNCIADA !
Postada em 22/01/2013 11:10 hs            
Pessoal estou com um problema sério em tentar fzr uma pesquisa no datagrid...preciso comparar tres textbox com tres colunas no grid e não to conseguindo. Alguém ai pode me ajudar. Já tentei de tudo mais não consigo.

Uso banco.mdb pra preencher o grid

Segue o meu código ai mais não esta fazendo nada, este código ai só funciona se eu preencher o datagrid sem usar o banco.mdb.

Alguém pode me dizer o que esta acontencendo!

        For i = 0 To DataGrid1.Rows.Count - 1
            If DataGrid1.Rows(i).Cells(1).Value = textbox1.Text And _
            DataGrid1.Rows(i).Cells(2).Value = textbox2.Text And _
            DataGrid1.Rows(i).Cells(3).Value = textbox3.Text Then
    

            Me.DataGrid1.MinDisplayedScrollingRowIndex = i
                Me.DataGrid1.Rows(i).Selected = True

                textbox4.Text = RS1.Fields(4).Value
                textbox5.Text = RS1.Fields(5).Value
                textbox6.Text = RS1.Fields(6).Value
                textbox7.Text = RS1.Fields(7).Value

  
            Else
                textbox4.Text = "?"
                textbox5.Text = "?"
                textbox6.Text = "?"
                textbox7.Text = "?"
            End If
            Exit Sub
        Next
   
AABernardi
TANGARÁ
SC - BRASIL
ENUNCIADA !
Postada em 22/01/2013 12:39 hs            
Já consegui fzr a pesquisa, só tive que mudar algumas coisas no código...confiram...

For i = 0 To DataGrid1.Rows.Count - 1
            If DataGrid1.Rows(i).Cells(1).Value = textbox1.Text.ToString And _
            DataGrid1.Rows(i).Cells(2).Value = textbox2.Text.ToString And _
            DataGrid1.Rows(i).Cells(3).Value = textbox3.Text.ToString Then

          Me.DataGrid1.SelectionMode = DataGridViewSelectionMode.FullRowSelect
                    Me.DataGrid1.MinDisplayedScrollingRowIndex = i
                    Me.DataGrid1.Rows(i).Selected = True
                    textbox4.Text = DataGrid1.Rows(i).Cells(5).Value

                   textbox5.Text = DataGrid1.Rows(i).Cells(6).Value
                   textbox6.Text = DataGrid1.Rows(i).Cells(7).Value
                   textbox7.Text = DataGrid1.Rows(i).Cells(8).Value
            Else
               'textbox4.Text = "?"
               'textbox5.Text = "?"
                'textbox6.Text = "?"
                'textbox7.Text = "?"
            End If
            Exit Sub
        Next

Não foi fácil mais consegui
Meu projeto só faltava isto, agora esta completinho...ABRAÇOS
   
Página(s): 1/1    


Seu Nome:

Seu eMail:

ALTERAR PARA MODO HTML
Mensagem:

[:)] = 
[:P] = 
[:(] = 
[;)] = 

HTML DESLIGADO

     
 VOLTAR

  



CyberWEB Network Ltda.    © Copyright 2000-2025   -   Todos os direitos reservados.
Powered by HostingZone - A melhor hospedagem para seu site
Topo da página