Bonjour;
Je souhaite créer des bouttons dynamiquement et qui peuvent se déplacer avec la souris.
voici le code ci-dessous qui fonctionne avec :
AddHandler m_TextBoxes(i).MouseHover, AddressOf mouvementqui relie mon action à la procédure "mouvement" qui doit laisser libre le déplacement des bouttons.... c'est cette procédure que je n'arrive pas à la créer.
Merci de votre aide.
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 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim nom_action As String nom_action = InputBox("Nom de l'action", "Sport Action") ' Get the index for the new control. Dim i As Integer = m_TextBoxes.Length ' Make room. ReDim Preserve m_TextBoxes(i) ' Create and initialize the control. m_TextBoxes(i) = New Button With m_TextBoxes(i) .Name = "TextBox" & i.ToString() + 1 If m_TextBoxes.Length < 2 Then ' Position the first one. .SetBounds(8, 8, 100, 20) Else ' Position subsequent controls. .Left = m_TextBoxes(i - 1).Left .Top = m_TextBoxes(i - 1).Top + m_TextBoxes(i - _ 1).Height + 4 .Size = m_TextBoxes(i - 1).Size End If ' Save the control's index in the Tag property. ' (Or you can get this from the Name.) m_TextBoxes(i).Tag = i.ToString '.Tag = i End With ' Give the control an event handler. AddHandler m_TextBoxes(i).MouseHover, AddressOf mouvement ' Add the control to the form. Me.Controls.Add(m_TextBoxes(i)) m_TextBoxes(i).Text = nom_action End Sub
Partager