Bonjour,
voici mon soucis. J'affiche dynamiquement des boutons à partir de ma base de données.
Ceci ce fait au load de ma form. J'ai créé un Event lors du chargement des boutons. Le but étant qu'en fonction du bouton sur lequel on clic, d'autres boutons s'affichent en rapport.
Cela fonctionne lorsque pour la première fois je clique sur n'importe quel bouton. Je passe bien à ce moment dans mon Event. Par contre, pour les suivants je n'y passe plus.
Voici mon code :
Quelqu'un aurait-il une idée sur la raison pour laquelle il ne passe q'une seule fois? Est-ce que mon appel à mon Event est mal positionné?
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 public void loadView() { caisse = new Caisse(); // Load Category buttons ButtonCategorie b; foreach (Categorie ca in caisse.getCatgories()) { b = new ButtonCategorie(ca); PanelCategorie.Controls.Add(b); b.Click += new EventHandler(b_Click); } btnPrecedent.Enabled = false; btnSuivant.Enabled = false; } // Event on Category void b_Click(object sender, EventArgs e) { buttonIndex = 0; ButtonCategorie b = (ButtonCategorie)sender; Categorie c = (Categorie)b.Tag; page = 1; MessageBox.Show(String.Format("{0}", c.Id)); displayProducts(c.Id, buttonIndex); } // Display Products private void displayProducts(int categorieId, int buttonIndex) { ButtonProducts b; ProductList = null; categorieID = categorieId; // Initialise the PanelProduct PanelProduit.Controls.Clear(); totalButtons = caisse.getProductbyCategory(categorieID).Count; totalPages = (step > 0 ? Math.Ceiling((decimal)(totalButtons / step)) : 0); ProductList = caisse.getProductbyCategory(categorieID); for (int i = 0; i < step; i++) { if (buttonIndex >= ProductList.Count()) return; b = new ButtonProducts(ProductList[i]); PanelProduit.Controls.Add(b); buttonIndex++; } checkNavigationButtons(); }
Merci pour votre aide.
Partager