Bonjour(soir)
je suis sur un appli windowform qui a une fonction pour créer plusieurs boutons à la lecture d'un fichier
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 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim ligne, name, group, dir, img As String Dim splitdata() Dim myStreamReader As StreamReader = New StreamReader("c:\rep\param.ini") Do ligne = myStreamReader.ReadLine() splitdata = Split(ligne, "|") name = splitdata(0) group = splitdata(1) dir = splitdata(2) img = splitdata(3) Dim createpanel As New Panel createpanel.Name = name createpanel.Size = New System.Drawing.Size(100, 100) createpanel.AutoSize = True Dim createbutton As New Button createbutton.Name = name createbutton.Size = New System.Drawing.Size(100, 100) createbutton.Text = name createpanel.Controls.Add(createbutton) FlowLayoutPanel1.Controls.Add(createpanel) Loop Until myStreamReader.EndOfStream End Sub
Je souhaiterai affecter la meme action sur chaque bouton mais avec des param dépendants du nom ou du text du bouton
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 Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim startparam(10) As String If Param0.Checked Then startparam(0) = "[param1]" End If If Param1.Checked Then startparam(1) = "[param2]" End If If Param2.Checked Then startparam(2) = "[param3]" End If If Param3.Checked Then startparam(3) = "[param4]" End If If Param4.Checked Then startparam(4) = "[param5]" End If If Param6.Checked Then startparam(6) = "[param6]" End If If Param7.Checked Then startparam(7) = "[param7]" End If If param8.Checked Then startparam(8) = "[param1]" End If Dim site = "nom_du_button" Shell("c:\rep\mon.exe [site=" & site & "]" & startparam(0) & startparam(1) & startparam(2) & startparam(3) & startparam(4) & startparam(5) & startparam(6) & startparam(7) & startparam(8) & startparam(9)) End Sub
En résumé j'aimerai que chaque button appelle cette fonction et envoi comem param son nom dansMerci pour votre aide
Code : Sélectionner tout - Visualiser dans une fenêtre à part Dim site = "nom_du_button"
Partager