Bonsoir, cela fait deux jours j'ai essayé de résoudre le problème de CurrencyManager mais en vain. Mon problème c'est que je n'arrive pas à balayer les enregistrement dans DataSet. Quelqu'un peut-il m'aider à résoudre mon problème S.V.P. Merci d'avance
Voici mes codes:
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
 
/*Connection vers MySQL*/
using MySql.Data;
using MySql.Data.MySqlClient;
 
namespace prjTestCM
{
    public partial class Form1 : Form
    {
        private CurrencyManager objCM;
 
        public Form1()
        {
            InitializeComponent();
        }
 
        private void Form1_Load(object sender, EventArgs e)
        {
            // Open a connection to the SQL Server Northwind database. 
            // Modify the following line to connect with your MySQL Server and log on.
            MySqlConnection con = new MySqlConnection("server=localhost; user=admin; database=laserdisc; port=3306; password=secret;");
 
            // Open the Acteurs table.
            MySqlDataAdapter daCust = new MySqlDataAdapter("SELECT * FROM t_acteurs",con);
 
            // Store the Acteurs into a local table.
            DataSet ds = new DataSet();
            daCust.Fill(ds, "Acteurs");
 
            // Bind the TextBox controls to the fields of the Acteurs table.
            textBox1.DataBindings.Add("Text", ds.Tables["Acteurs"], "ID_ACTEUR");
            textBox2.DataBindings.Add("Text", ds.Tables["Acteurs"], "PRENOM_ACTEUR");
            textBox3.DataBindings.Add("Text", ds.Tables["Acteurs"], "NOM_ACTEUR");
 
            // Specify the CurrencyManager for the Acteurs table.
            objCM = (CurrencyManager)this.BindingContext[ds.Tables["Employees"]];
 
            // Specify the event handlers for the CurrencyManager.
            objCM.CurrentChanged += new EventHandler(Current_Changed);
            objCM.ItemChanged += new ItemChangedEventHandler(CurrencyManager_ItemChanged);
            objCM.PositionChanged += new EventHandler(Position_Changed);
        }
 
        private void Current_Changed(object sender, EventArgs e)
        {
            MessageBox.Show("Current_Changed");
        }
 
        private void CurrencyManager_ItemChanged(object sender, System.Windows.Forms.ItemChangedEventArgs e)
        {
            MessageBox.Show("Item_Changed");
        }
 
        private void Position_Changed(object sender, EventArgs e)
        {
            MessageBox.Show("Position_Changed");
        }
 
        private void cmdFirst_Click(object sender, EventArgs e)
        {
            // Move to the first row in the DataTable.
            objCM.Position = 0;
        }
 
        private void cmdPrevious_Click(object sender, EventArgs e)
        {
            // If you are positioned past the first row,
            if (objCM.Position > 0)
            {
                // move back one row.
                objCM.Position -= 1;
            }
        }
 
        private void cmdNext_Click(object sender, EventArgs e)
        {
            // If you are positioned before the last row,
            if (objCM.Position < objCM.Count)
            {
                //move back one row.
                objCM.Position += 1;
            }
        }
 
        private void cmdLast_Click(object sender, EventArgs e)
        {
            // Position at the last row.
            objCM.Position = objCM.Count;
        }
 
        private void cmdCancelEdit_Click(object sender, EventArgs e)
        {
            // Cancel the current editing in the bound controls.
            objCM.CancelCurrentEdit();
        }
    }//Fin cls.
}