Click here to Skip to main content
15,886,639 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have buuttons which are going to be created at runtime. so i should be able to move that buttons with code. for that i know i should use
VB
Private Sub Runtime Button Name_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles User.MouseDown

Similarly i should use Mouse Move and Mouse Up Events.


Problem here is I am not understanding how to name the runtime button so that i should be able to move that button.

Please help me how to name the button which is created at runtime.
Posted

1 solution

Give your method a generic name: "CreatedAtRunTimeButton_MouseDown" for example, and set all your created buttons to use the same handler. Then within the handler use the sender parameter (cast into a Button) to access which button was pressed.
VB
Dim b As Button = TryCast(sender, Button)
If b IsNot Nothing Then
    Dim text As String = b.Text
End If
 
Share this answer
 
Comments
Estys 22-Jan-11 5:27am    
You should really add the "AddHandler" bit for clarity.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900