Urgent! Je n'arrive pas à rendre la courbe invisible après un certain temps (Timer), je ne peux pas accèder au control "Chart1" déclaré dans "BackgroundWorker3_RunWorkerCompleted" à partir de "Timer5_Tick"
Un peux d'aide sera la bienvenue

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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
        Timer3.Stop()
        BackgroundWorker3 = New BackgroundWorker
        BackgroundWorker3.WorkerReportsProgress = True
        BackgroundWorker3.RunWorkerAsync()
        While BackgroundWorker3.IsBusy()
            Windows.Forms.Application.DoEvents()
        End While
        Timer5.Interval = 15000
        Timer5.Start()
    End Sub

Private Sub BackgroundWorker3_DoWork(ByVal sender As System.Object, ByVal e As DoWorkEventArgs) Handles BackgroundWorker3.DoWork
        Dim worker As BackgroundWorker = DirectCast(sender, BackgroundWorker)
        Try
            connection.Close()
            Dim sql4 As String = "SELECT ThreatType, Count FROM EPOEvents_ThreatTypesView  ORDER BY Count DESC"
            Dim dataadapter4 As New SqlDataAdapter(sql4, connection)
            connection.Open()
            dataadapter4.Fill(dt4)
        Catch ex As Exception

        End Try
    End Sub

    Private Sub BackgroundWorker3_RunWorkerCompleted(ByVal sender As Object, _
                                            ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker3.RunWorkerCompleted
        Dim ChartArea1 As ChartArea = New ChartArea()
        Dim Legend1 As Legend = New Legend()
        Dim Series1 As Series = New Series()
        Dim Chart1 = New DataVisualization.Charting.Chart()
        Me.Controls.Add(Chart1)
        Chart1.DataSource = dt4

        ChartArea1.Name = "ChartArea1"
        Chart1.ChartAreas.Add(ChartArea1)
        Chart1.Size = New System.Drawing.Size(980, 600)
        Chart1.BorderSkin.SkinStyle = BorderSkinStyle.Sunken
        Chart1.BorderSkin.BorderDashStyle = ChartDashStyle.Solid
        Chart1.BorderSkin.BackColor = Color.Red
        Chart1.BorderSkin.BackSecondaryColor = Color.Blue
        Chart1.BorderSkin.BackHatchStyle = ChartHatchStyle.DarkVertical
        Legend1.Name = "Legend1"
        Chart1.Legends.Add(Legend1)
        Chart1.Location = New System.Drawing.Point(20, 150)
        Chart1.Name = "Chart1"
        Series1.ChartArea = "ChartArea1"
        Series1.Legend = "Legend1"
        Series1.Name = "ThreatStat"
        Chart1.Series.Add(Series1)
        Chart1.TabIndex = 0
        Chart1.Text = "Chart1"
        Chart1.Series("ThreatStat").XValueMember = "ThreatType"
        Chart1.Series("ThreatStat").YValueMembers = "Count"
        Chart1.Series("ThreatStat").Font = New Font("Arial", 13, FontStyle.Bold)
        Chart1.Series("ThreatStat").IsValueShownAsLabel = True
        Chart1.Series("ThreatStat").LabelForeColor = Color.Firebrick
        Chart1.Series(0).Color = Color.FromArgb(128, Color.Blue)
        Chart1.Series(0).IsVisibleInLegend = False
        Chart1.AlignDataPointsByAxisLabel()
        Series1.ChartType = SeriesChartType.Column
        Chart1.ChartAreas("ChartArea1").Area3DStyle.Enable3D = True
        Chart1.ChartAreas("ChartArea1").Area3DStyle.Rotation = 40
        Chart1.ChartAreas("ChartArea1").Area3DStyle.Inclination = 90
        Chart1.ChartAreas("ChartArea1").Area3DStyle.PointDepth = 100
        Chart1.ChartAreas("ChartArea1").Area3DStyle.PointGapDepth = 0
        Chart1.ChartAreas(0).Area3DStyle.WallWidth = 10
        Chart1.ChartAreas(0).Area3DStyle.LightStyle = LightStyle.Realistic
        ChartArea1.AxisX.LabelStyle.Angle = -55
        ChartArea1.AxisX.LabelStyle.Font = New Font("Verdana", 10, FontStyle.Bold)
        ChartArea1.AxisY.LabelStyle.Font = New Font("Verdana", 10, FontStyle.Bold)
        ChartArea1.AxisX.Interval = 1
        Chart1.Height = Chart1.Height - 15
    End Sub

    Private Sub Timer5_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer5.Tick
        Timer5.Stop()

        Chart1.visible = False

        Me.BackgroundImage = System.Drawing.Image.FromFile("C:\Documents and Settings\atel_deco\Mes documents\Visual Studio 2005\Projects\background worker\background worker\sagemcom_logo.jpg")
        Me.BackgroundImageLayout = ImageLayout.Center
        .
        .
        .
        .
    End Sub