Voici la première portion de code , au lancement tout est ok, l'affichage dans le datagrid, est bon suivant la requete, mais lorsque je change de date dans le datetimepicker ( ChoixDate ) le datagrid se vite ( correcte), mais ne se rempli plusavec la nouvelle valeur de date,................. Why?


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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
 
Imports System.Data
Imports System.Data.OleDb
 
Public Class FrmMain
 
 
    Dim CxnCalendar As String
    Dim CxnFactory As String
    Dim CxnOle As OleDbConnection
    Dim DaCalendar As OleDbDataAdapter
    Dim DsCalendar As DataSet
    Dim BsNotes As BindingSource
    Dim BsFactory As BindingSource
    Dim StringSql As String
 
 
 
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        DeclareDLL() ' appel fonction declaration DLL preview5
 
        StringSql = "SELECT * FROM Notes WHERE DateNote=#" & DateString & "#"
        Me.TopMost = True  ' affiche toujours le prg en avant plan
 
        Me.CxnCalendar = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\Visual Basic\isg\Calendar.mdb"
        Me.CxnOle = New OleDbConnection
        Me.CxnOle.ConnectionString = Me.CxnCalendar
 
        Me.DsCalendar = New DataSet
 
        Me.CxnOle.Open()
 
        Me.DaCalendar = New OleDbDataAdapter(StringSql, CxnOle)
        Me.DaCalendar.Fill(Me.DsCalendar, "notes")
 
        Me.DaCalendar = New OleDbDataAdapter("SELECT * FROM Factory", CxnOle)
        Me.DaCalendar.Fill(Me.DsCalendar, "Factory")
 
        Me.CxnOle.Close()
 
        BsNotes = New BindingSource(DsCalendar, "notes")
        BsFactory = New BindingSource(DsCalendar, "Factory")
 
        Me.DataGrid.DataSource = Me.BsNotes
 
        Me.TextBox1.DataBindings.Add(New Binding("text", Me.BsFactory, "chrono"))
        Me.TextBox2.DataBindings.Add(New Binding("Text", Me.BsNotes, "DateNote"))
        Me.TextBox3.DataBindings.Add(New Binding("text", Me.BsNotes, "note"))
 
        AfficheData()
 
    End Sub
 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
 
        End
 
    End Sub
 
    Public Sub AfficheData()
 
        ' positionne la form dans le coin supérieur droit de l'écran
        '        Me.Left = Screen.PrimaryScreen.WorkingArea.Width - Me.Width
        '        Me.Top = 0
 
        With Me.DataGrid
 
            .Size = New Size(Me.Width - 5, Me.Height - 120) ' redimensionne le datagrid en fonction du form
            .Location = New Point(0, 35) ' positione le datagrid dans le coins superieur gauche du form
            .RowHeadersVisible = False
            .ScrollBars = ScrollBars.Vertical
            .ColumnHeadersVisible = False
            .Columns(0).Visible = False
            .Columns(1).Visible = False
            .Columns(2).Width = .Width - 20
            .Columns(3).Visible = False
            .Focus()
 
        End With
 
        Timer1.Enabled = True
 
 
    End Sub
 
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
 
        'Me.ChoixDate.Value = Date.Now
 
        'StringSql = "SELECT * FROM Notes WHERE DateNote=#" & DateString & "#"
 
 
    End Sub
 
    Private Sub ChoixDate_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs)
 
        Timer1.Enabled = False
 
    End Sub
 
    Private Sub ChoixDate_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs)
 
        Timer1.Enabled = True
 
    End Sub
 
 
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        With Preview
            .AddTextAt("coucou", "20 mm", "20 mm")
            .EndDocument()
        End With
    End Sub
 
    Private Sub ChoixDate_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChoixDate.ValueChanged
 
        StringSql = "SELECT * FROM Notes WHERE DateNote=#01/12/2006#"
 
        Me.DsCalendar.Tables("notes").Clear()
        Me.CxnOle.Open()
 
        Me.DaCalendar = New OleDbDataAdapter(StringSql, CxnOle)
        Me.DaCalendar.Fill(Me.DsCalendar, "notes")
        Me.CxnOle.Close()
 
        AfficheData()
 
    End Sub
 
 
End Class