Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a button that can move and resize during runtime, and new buttons can be created during runtime with these same proprities and events. Now i need to be able to save the size and location(Top, Left) of these buttons that will be created during runtime.

In other words how do u save the size and location of any button on the form.

This is the code i use to generate new buttons.
VB
Dim i As Integer = 0
    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        Dim btn1 As New Button
        btn1.Name = "Ad" + i.ToString
        btn1.Text = "ad" + i.ToString
        AddHandler btn1.MouseMove, AddressOf Button1_MouseMove
        AddHandler btn1.MouseDown, AddressOf Button1_MouseDown
        AddHandler btn1.MouseUp, AddressOf Button1_MouseUp
        Me.Controls.Add(btn1)
        btn1.BringToFront()
        i += 1
    End Sub
Posted
Comments
Ralf Meier 22-Jun-15 5:44am    
If you do this during DesignTime the Designer writes this Information in the Design-Script of the Parent.
If you do this during the Runtime and wish that this Setting is memorisized you have to build up you own Serializer which works for your purpose.

1 solution

Your question is not clear.

in my understanding you have attached events like mousedown and mousemove so in these events you can track the buttons properties and save it wherever you need.
 
Share this answer
 

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