Form Designer

L

Lou

Is there a runtime form designer that comes with vs2005 or vs2008.
I need a control to allow users to add and position controls on a form.

-Lou
 
K

kimiraikkonen

Is there a runtime form designer that comes with vs2005 or vs2008.
I need a control to allow users to add and position controls on a form.

-Lou

As far as i know, there is no built-in solution for behaving like
desinger at runtime. Instead, you need to manipulate objects
dynamically by writing your own code. However there may be 3rd party
commercial components that may allow this.

And regarding to your aim, you can add controls to your form
dynamically by using <form>.Controls.Add method after you've
instantiated them. And in the same way for setting their position as
follows:

' Eg. Add a button at runtime
Dim mybutton As New Button
mybutton.Text = "My Button"
' Allow users to specify button's
' position here
mybutton.Location = New Point(100,100)
' Add it
Me.Controls.Add(mybutton)

Additonaly, for moving your control at runtime by dragging with mouse
cursor, you can check this snippet on:
http://bytes.com/forum/thread378975.html

And as the courtesy of the link above, the code:

'---------------Begin----------------
Private dragging As Boolean
Private beginX, beginY As Integer

Private Sub Button1_MouseDown(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles Button1.MouseDown

dragging = True
beginX = e.X
beginY = e.Y

End Sub

Private Sub Button1_MouseMove(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles Button1.MouseMove
If dragging = True Then
Button1.Location = New Point(Button1.Location.X _
+ e.X - beginX, Button1.Location.Y + e.Y - beginY)
Me.Refresh()
End If
End Sub

Private Sub Button1_MouseUp(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles Button1.MouseUp

dragging = False

End Sub
'---------------End------------------

Hope this helps,

Onur Güzel
 
L

Lou

That's awesome.
Thanks you.
-Lou

Is there a runtime form designer that comes with vs2005 or vs2008.
I need a control to allow users to add and position controls on a form.

-Lou

As far as i know, there is no built-in solution for behaving like
desinger at runtime. Instead, you need to manipulate objects
dynamically by writing your own code. However there may be 3rd party
commercial components that may allow this.

And regarding to your aim, you can add controls to your form
dynamically by using <form>.Controls.Add method after you've
instantiated them. And in the same way for setting their position as
follows:

' Eg. Add a button at runtime
Dim mybutton As New Button
mybutton.Text = "My Button"
' Allow users to specify button's
' position here
mybutton.Location = New Point(100,100)
' Add it
Me.Controls.Add(mybutton)

Additonaly, for moving your control at runtime by dragging with mouse
cursor, you can check this snippet on:
http://bytes.com/forum/thread378975.html

And as the courtesy of the link above, the code:

'---------------Begin----------------
Private dragging As Boolean
Private beginX, beginY As Integer

Private Sub Button1_MouseDown(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles Button1.MouseDown

dragging = True
beginX = e.X
beginY = e.Y

End Sub

Private Sub Button1_MouseMove(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles Button1.MouseMove
If dragging = True Then
Button1.Location = New Point(Button1.Location.X _
+ e.X - beginX, Button1.Location.Y + e.Y - beginY)
Me.Refresh()
End If
End Sub

Private Sub Button1_MouseUp(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles Button1.MouseUp

dragging = False

End Sub
'---------------End------------------

Hope this helps,

Onur Güzel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top