Ralentissement entre 2 datagridview
Bonjour à tous
Dans ma fenêtre, je possède 2 dataGridView.
Quand je sélectionne dans un datagrid, le 2e datagrid se change en fonction des abonnements d'un membre.
C'est très long changer de rangée de le datagrid, ce n'est plus fluide comme avant.
C'est peut-être du au code qui est trop lourd...
Voici la manipulation que je fais :
Code:
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
| public void RemplirGridMembre()
{
con.InitialiserConnection();
MySqlDataAdapter adapter = new MySqlDataAdapter("SELECT idMembre,prenom,nom FROM membre ORDER BY idMembre DESC ", con.ConnectionBD);
DataTable table = new DataTable();
adapter.Fill(table);
BindingSource bSource = new BindingSource();
bSource.DataSource = table;
DataGridView dgView = new DataGridView();
dataGridView1.DataSource = bSource;
dataGridView1.Columns[0].Width = 30;
dataGridView1.Columns[0].HeaderText = "ID";
dataGridView1.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView1.Columns[1].HeaderText = "Prénom";
dataGridView1.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView1.Columns[2].HeaderText = "Nom";
} |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| public void RemplirGridAbonnement()
{
con.InitialiserConnection();
membre.IdMembre = Convert.ToInt32(txtIdMembre.Text);
MySqlDataAdapter adapter = new MySqlDataAdapter("SELECT t3.idActivite, t3.nom FROM abonnement AS t1 INNER JOIN membre AS t2 ON (t1.idMembre = t2.idMembre) INNER JOIN activite AS t3 ON (t3.idActivite= t1.idActivite) WHERE t1.idMembre = " + membre.IdMembre+"", con.ConnectionBD);
DataTable table = new DataTable();
adapter.Fill(table);
BindingSource bSource = new BindingSource();
bSource.DataSource = table;
DataGridView dgView = new DataGridView();
dataGridView2.DataSource = bSource;
dataGridView2.Columns[0].Width = 30;
dataGridView2.Columns[0].HeaderText = "ID";
dataGridView2.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView2.Columns[1].HeaderText = "Nom";
} |
Code:
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
| private void dataGridView1_CurrentCellChanged(object sender, EventArgs e)
{
if (dataGridView1.CurrentRow != null)
{
index = dataGridView1.CurrentCell.RowIndex;
int valeur = Convert.ToInt32(dataGridView1[0, index].Value);
membre = membre.GetById(valeur);
txtIdMembre.Text = membre.IdMembre.ToString();
txtPrenom.Text = membre.Prenom.ToString();
txtNom.Text = membre.Nom.ToString();
txtDateNaissance.Text = membre.DateNaissance.ToString();
txtAdresse.Text = membre.Adresse.ToString();
txtCodePostal.Text = membre.CodePostal.ToString();
txtVille.Text = membre.Ville.ToString();
txtMaison.Text = membre.TelMaison.ToString();
txtCellulaire.Text = membre.TelCellulaire.ToString();
txtCourriel.Text = membre.Courriel.ToString();
txtMotPasse.Text = membre.MotPasse.ToString();
}
RemplirGridAbonnement();
} |