Bonjour à tous,
Voila plusieurs heures que je butte sur un petit problème "à la con".
Sans doutes que quelqu'un pourra m'aider ?

Dans ma form "principale" je créé (entre autre) une checkbox et 2 label comme suit :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
 
sub ajtlign()
ReDim Preserve ChkbxElegDispFisc(contLogmt)
        ChkbxElegDispFisc(contLogmt) = New CheckBox
        With ChkbxElegDispFisc(contLogmt)
            .Top = 10 + 25 * contLogmt
            .Left = 430
            .Text = "Eligible dispositif fiscal"
            .Visible = True
            .Width = 130
           .Tag = contLogmt
        End With
        AddHandler ChkbxElegDispFisc(contLogmt).CheckedChanged, AddressOf DispFiscal
        TabPage2.Controls.Add(ChkbxElegDispFisc(contLogmt))
 
        ReDim Preserve EtqDureeDispFisc(contLogmt)
        EtqDureeDispFisc(contLogmt) = New Label
        With EtqDureeDispFisc(contLogmt)
            .Top = 10 + 25 * contLogmt
            .Left = 750
            .Width = 50
            '.Text = "duréeDispFisc"
            .Visible = True
        End With
        TabPage2.Controls.Add(EtqDureeDispFisc(contLogmt))
 
        ReDim Preserve EtqDeducDispFisc(contLogmt)
        EtqDeducDispFisc(contLogmt) = New Label
        With EtqDeducDispFisc(contLogmt)
            .Top = 10 + 25 * contLogmt
            .Left = 800
            '.Text = "deducDispFisc"
            .Visible = True
        End With
        TabPage2.Controls.Add(EtqDeducDispFisc(contLogmt))
end sub
 
Sub DispFiscal()
        For i = 1 To contLogmt Step 1
            If ChkbxElegDispFisc(i).Checked Then
                Form_DispFiscal.Show()
            End If
        Next 'i
    End Sub
Vous l'aurez compris, lorsque l'utilisateur coche la checkbox, une fenêtre s'affiche.
Dans celle-ci l'utilisateur il doit renseigner deux champs (TextBox_DeducFisc et TextBox_DureeDispFic).
Une fois que l'utilisateur aura validé sa saisie, les deux label crées dynamiquement dans la form principale devront afficher la saisie de l'utilisateur.
Pour ce faire je pensais utiliser le code suivant (dans la form DispFiscal):
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
 Public ChkBox_Org As CheckBox
 
    Private Sub Button_Valid_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_Valid.Click
 
            ChkBox_Org = (TryCast(sender, CheckBox))
            Form_Principale.EtqDeducDispFisc(ChkBox_Org.Tag).Text = TextBox_DeducFisc.Text
            Form_Principale.EtqDureeDispFisc(ChkBox_Org.Tag).Text = TextBox_DureeDispFic.Text
            Me.Close()
 
    End Sub
Malheureusement ce code ne fonctionne pas (ça aurait été trop beau)

J'aimerai également que si l'utilisateur décoche puis recoche la checkbox, les informations qu'il avait saisi précédemment soient affichées dans les textbox de la fenêtre.
Je pensais donc utiliser le code suivant :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
 Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
              ChkBox_Org = (TryCast(sender, CheckBox))
        'MsgBox(Form_Principale.ChkBox_Org.Tag)
        TextBox_DeducFisc.Text = Form_Principale.EtqDeducDispFisc(ChkBox_Org.Tag).Text
        TextBox_DureeDispFic.Text = Form_Principale.EtqDureeDispFisc(ChkBox_Org.Tag).Text
    End Sub
Ce code en fonctionne pas non plus ...

Vraisemblablement je n'arrive pas à récupérer le tag de la checkbox d'orgine.
Quelqu'un aurait une idée ?

Merci d'avance pour votre aide