Jump to content
Fórum Script Brasil
  • 0

Busca no datagridview


mestre fyoda

Question

Dim it As ListViewItem = Campo_ListView.FindItemWithText(Campo_TextBox.Text, False, 0, True)
                Campo_ListView.SelectedItems.Clear()
                Campo_ListView.Items(it.Index).Selected = True
                Campo_ListView.Items(it.Index).EnsureVisible()

No listview eu uso esse codigo acima e ele me retorna a linha exata, mas teria lago equivalente no datagridview ?

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Seria algo assim:

Dim célula As DataGridViewCell
Dim i As Integer = 0

For Each r As DataGridViewRow In dg.Rows
    célula = r.Cells(i)
    If célula.Value = "blá" Then
        r.Selected = True
    End If
Next

Onde "dg" é a DataGridview, "i" é o índice da coluna desejada (começando de zero) e ""blá"" é o texto a ser procurado.

Abraços,

Graymalkin

Link to comment
Share on other sites

  • 0

Dim célula As DataGridViewCell
        Dim i As Integer = 0

        For Each r As DataGridViewRow In dtg_cliente.Rows
            célula = r.Cells(i)
            If célula.Value = txt_procurar.Text Then
                r.Selected = True
            End If
        Next
este codigo só funciona com numeros, pois eu estou usando no campo texto numeros no formato 999.999.999-99 ou no formato numerico ! Quando uso o formato 999.999.999-99 da esse erro :
Conversion from string "302.672.168-90" to type 'Double' is not valid.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152k
    • Total Posts
      651.5k
×
×
  • Create New...