通过复选框VB过滤datagridview

时间:2014-09-08 12:56:50

标签: vb.net checkbox datagridview filter

我是vb的初学者,我想通过复选框过滤我的datagridview,我尝试了这段代码,但似乎没有用。

`Public Class besoins

Private Sub EtablissementsBindingNavigatorSaveItem_Click(sender As System.Object, e As System.EventArgs) Handles EtablissementsBindingNavigatorSaveItem.Click
    Me.Validate()
    Me.EtablissementsBindingSource.EndEdit()
    Me.TableAdapterManager.UpdateAll(Me.Base_de_données2DataSet)

End Sub

Private Sub besoins_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    'TODO: cette ligne de code charge les données dans la table 'Base_de_données2DataSet.etablissements'. Vous pouvez la déplacer ou la supprimer selon vos besoins.
    Me.EtablissementsTableAdapter.Fill(Me.Base_de_données2DataSet.etablissements)
    With DataGridView
        .clearselection()
        .ReadOnly = True
        .MultiSelect = False

    End With

End Sub

Private Sub bt_chercher_Click(sender As System.Object, e As System.EventArgs) Handles bt_chercher.Click
    Dim CustomFilter As String
    CustomFilter = Me.EtablissementsBindingSource.Filter

                If cb_dur.Checked = True Then
        CustomFilter = CustomFilter + "Dur = 'NON' AND "
                ElseIf cb_administra.Checked = True Then
        CustomFilter = CustomFilter + "Administration = 'NON' AND "
                ElseIf cb_assoc.Checked = True Then
        CustomFilter = CustomFilter + "association = 'NON' AND "
                ElseIf cb_biblio.Checked = True Then
        CustomFilter = CustomFilter + "biblio = 'NON' AND "
                ElseIf cb_blocBranc.Checked = True Then
        CustomFilter = CustomFilter + "bloc branché = 'NON' AND "
                ElseIf cb_branEau.Checked = True Then
        CustomFilter = CustomFilter + "branché eau = 'NON' AND "
                ElseIf cb_branElect.Checked = True Then
        CustomFilter = CustomFilter + "branché électricité = 'NON' AND "
                ElseIf cb_citerne.Checked = True Then
        CustomFilter = CustomFilter + "citerne = 'NON' AND "
                ElseIf cb_dafira.Checked = True Then
        CustomFilter = CustomFilter + "dafira = 'NON' AND "
                ElseIf cb_eau.Checked = True Then
                ElseIf cb_fosSyp.Checked = True Then
        CustomFilter = CustomFilter + "fosse syptique = 'NON' AND "
                ElseIf cb_logement.Checked = True Then
        CustomFilter = CustomFilter + "logements = 'NON' AND "
                ElseIf cb_prefabrique.Checked = True Then
        CustomFilter = CustomFilter + "préfabriqué = 'NON' AND "
                ElseIf cb_puit.Checked = True Then
        CustomFilter = CustomFilter + "Administration = 'NON' AND "
                ElseIf cb_reseau.Checked = True Then
        CustomFilter = CustomFilter + "reseau = 'NON' AND "
                ElseIf cb_salProf.Checked = True Then
        CustomFilter = CustomFilter + "salle prof = 'NON' AND "
                ElseIf cb_wc.Checked = True Then
        CustomFilter = CustomFilter + "wc = 'NON' "
                End If
End Sub

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    acceuil.Show()
    Me.Hide()

End Sub

Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
    Me.Close()

End Sub

结束课程

我正在尝试找出一种更好的过滤/搜索方法,但我还没有想出任何解决方案。有任何想法吗?谢谢你:))

0 个答案:

没有答案