Jump to content

Filtragens do ListView


lusky
 Share

Go to solution Solved by Retsu9,

Recommended Posts

Boas Noites,

Tenho o seguinte código feito para uma filtragem numérica de uma listview e funciona bem, o meu problema agora é acrescentar a este código mais um filtro mas que filtre texto, neste caso a palavra "Ruptura" e não estou a conseguir....

Mostro-vos o código para que entendam melhor:

Private Sub MontaLista()
txt1.Text = Date.Today()
Try
Dim SQL As String = "select * from Agenda"
Dim where As String = ""
If Not txtBuscar.Text = "" Then
If cmbFiltro.Text = "Fornecedor" Then
where = " where Fornecedor = " & txtBuscar.Text
Else
where = " where Itm8 like '%" & txtBuscar.Text & "%'"
End If
End If
SQL += where
ds.Reset()
Dim adptr As New OleDbDataAdapter(SQL, conect_banco)
adptr.Fill(ds)
dt = ds.Tables(0)
LV1.Items.Clear()
Dim Item As ListViewItem
For Each Me.dr In dt.Rows
Item = LV1.Items.Add(dr.Item("ID"))
Item.SubItems.Add(dr.Item("Itm8"))
Item.SubItems.Add(dr.Item("Designacao"))
Item.SubItems.Add(dr.Item("Fornecedor"))
Item.SubItems.Add(dr.Item("Motivo"))
Item.SubItems.Add(dr.Item("Registo"))
Next
Catch ex As Exception
MsgBox("Erro: " & ex.Message)
End Try
End Sub

Esse código acima está funcional mas tento colocar este filtro e retorna sempre erro:

If cmbFiltro.Text = "Motivo" Then
where = " where Motivo = " & txtBuscar.Text
End If

Agradecendo a Vossa ajuda.

Cumps,

Edited by apocsantos
geshi
Link to comment
Share on other sites

Boas,

É possível selecionar um segundo filtro na ListView após o primeiro já estar carregado?

Isto é:

Tenho 1 Combobox + TextBox com o seguinte código:

If cmbFiltro.Text = "Fornecedor" Then

where = " where Fornecedor = " & txtBuscar.Text

Else

where = " where Itm8 like '%" & txtBuscar.Text & "%'"

End If

Agora queria acrescentar mais uma combobox e mais uma textbox para fazer uma filtragem sobre a primeira, não sei como me explicar melhor...

Agradecendo antecipadamente,

Cumprimentos,

Edited by apocsantos
geshi
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.