Form Designer

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lou

    Form Designer

    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


  • kimiraikkonen

    #2
    Re: Form Designer

    On Nov 16, 6:31 am, "Lou" <lou.gar...@com cast.netwrote:
    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.Locati on = 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:


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

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

    Private Sub Button1_MouseDo wn(ByVal sender As Object, _
    ByVal e As System.Windows. Forms.MouseEven tArgs) _
    Handles Button1.MouseDo wn

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

    End Sub

    Private Sub Button1_MouseMo ve(ByVal sender As Object, _
    ByVal e As System.Windows. Forms.MouseEven tArgs) _
    Handles Button1.MouseMo ve
    If dragging = True Then
    Button1.Locatio n = New Point(Button1.L ocation.X _
    + e.X - beginX, Button1.Locatio n.Y + e.Y - beginY)
    Me.Refresh()
    End If
    End Sub

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

    dragging = False

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

    Hope this helps,

    Onur Güzel

    Comment

    • Lou

      #3
      Re: Form Designer

      That's awesome.
      Thanks you.
      -Lou

      "kimiraikko nen" <kimiraikkonen8 5@gmail.comwrot e in message
      news:3f210948-31c6-4dcb-b66c-5fceb94a536a@f3 7g2000pri.googl egroups.com...
      On Nov 16, 6:31 am, "Lou" <lou.gar...@com cast.netwrote:
      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.Locati on = 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:


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

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

      Private Sub Button1_MouseDo wn(ByVal sender As Object, _
      ByVal e As System.Windows. Forms.MouseEven tArgs) _
      Handles Button1.MouseDo wn

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

      End Sub

      Private Sub Button1_MouseMo ve(ByVal sender As Object, _
      ByVal e As System.Windows. Forms.MouseEven tArgs) _
      Handles Button1.MouseMo ve
      If dragging = True Then
      Button1.Locatio n = New Point(Button1.L ocation.X _
      + e.X - beginX, Button1.Locatio n.Y + e.Y - beginY)
      Me.Refresh()
      End If
      End Sub

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

      dragging = False

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

      Hope this helps,

      Onur Güzel


      Comment

      Working...