-
Form.Height?
I'm trying to move a command button to the buttom of a form, but sounds like I'm having a problem
btnAdd.Location = New Drawing.Point(360, Me.Height - btnAdd.Height)
This way the button will be outside the form, but if I use this code instead, it will work
btnAdd.Location = New Drawing.Point(360, Me.Height - btnAdd.Height - 30)
Why do I have to subtract 30 pixels?:confused: is that for the titlebar perhaps?
-
Here's how I place button on a form using Me.ClientSize as the best way imho:-
Dim btn as New Button
'place on bottom-left
btn.Top = Me.ClientSize.Height - btn.Height
btn.Left = 0
btn.Text = "Bottom"
Me.Controls.Add(btn)
'place on bottom-right
btn = New Button()
btn.Top = Me.ClientSize.Height - btn.Height
btn.Left = Me.ClientSize.Width - btn.Width
btn.Text = "Bottom-Right"
Me.Controls.Add(btn)
'place on top-left
btn = New Button()
btn.Top = 0
btn.Left = 0
btn.Text = "Top-Left"
Me.Controls.Add(btn)
'place on top-right
btn = New Button()
btn.Top = 0
btn.Left = Me.ClientSize.Width - btn.Width
btn.Text = "Top-Right"
Me.Controls.Add(btn)
-
-
This way works
I dont think the way above works try 1 of these insted, which one is just a matter of choice
Dim B As New Button()
Dim P As New PointF(100.0, 100.0)
B.Text = "Button"
B.Location = B.Location.Ceiling(P)
Me.Controls.Add(B)
or
Dim B As New Button()
B.Text = "Button"
B.Location = B.Location.Ceiling(New PointF(100.0, 100.0))
Me.Controls.Add(B)
I know for a fact, these ways work
-
this is the easiest
i almost forgot this way is the easiest
Dim B As New Button()
B.Text = "Button"
B.Location = New Point(500, 100)
Me.Controls.Add(B)
the other ways use the "ceiling" which rounds "pointf", this way you can just plot with a point.