从表单获取CheckedItems到UserControl vb

时间:2016-02-01 11:04:54

标签: .net vb.net winforms user-controls checkboxlist

我有一个Form(名称= FrmIndicateurs),其中包含一个CheckListBox(名称= ClbOrga)和一个Usercontrol

在我的UserControl中,我有一个按钮(name = button2)需要为ClbOrga中的每个检查项做一些事情

问题是,似乎创建了Checklistbox的新实例,而不是获取当前的Checklistbox

我对编程很陌生,所以如果它是“基本的”我很抱歉 你有解决方案吗?

(visual studio 2008)

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    Dim message As String = "Etes vous sûr ?"
    Dim reponse As MsgBoxResult
    Dim style As MsgBoxStyle
    style = MsgBoxStyle.YesNo
    reponse = MsgBox(message, style, "Validation")

    If reponse = MsgBoxResult.Yes Then

        For Each orga As Communs.CLBItem In FrmIndicateurs.ClbOrga.CheckedItems

            Dim IdOrga As Integer
            Dim datao As New DataSet
            Dim requete2 As String = "SELECT IDOrganisation FROM Organisations WHERE Nom = @P1"
            Data.SqlExecute(datao, requete2, 1, Variables.DbcConnection, orga.Nom)
            For Each r As DataRow In datao.Tables(0).Rows

                IdOrga = CInt(r("IDOrganisation"))

            Next

            Dim IdIndicateur As Integer
            Dim Datai As New DataSet
            Dim requete1 As String = " SELECT IDIndicateur FROM Indicateurs WHERE Nom = @P1"
            Data.SqlExecute(Datai, requete1, 1, Variables.DbcConnection, Label4.Text)
            For Each r As DataRow In Datai.Tables(0).Rows

                IdIndicateur = CInt(r("IDIndicateur"))

            Next

            Dim Datar As New DataSet
            Dim requete As String = "DELETE FROM Valeurs WHERE IDOrganisation = @P2 AND IDIndicateur = @P1"

            Data.SqlExecute(Datar, requete, 2, Variables.DbcConnection, IdIndicateur, IdOrga)
        Next

    End If
End Sub

0 个答案:

没有答案