|
-
Mar 25th, 2018, 06:12 PM
#5
Re: Text Box docked to top of form, do I have to manually adjust the height?
 Originally Posted by .paul.
You can use a TableLayoutPanel. That will allow docking, handle resizing, and allow a fixed 22px gap at the bottom of the form...
Code:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim tlp As New TableLayoutPanel
tlp.RowCount = 2
tlp.ColumnCount = 1
tlp.Dock = DockStyle.Fill
Me.Controls.Add(tlp)
Dim tb As New TextBox With {.Dock = DockStyle.Fill, .Multiline = True, .BackColor = Color.Red}
tlp.Controls.Add(tb)
Dim p As New Panel With {.Dock = DockStyle.Fill}
tlp.Controls.Add(p)
tlp.RowStyles.Add(New RowStyle(SizeType.Percent, 100))
tlp.RowStyles.Add(New RowStyle(SizeType.Absolute, 22))
tlp.SetColumn(tb, 0)
tlp.SetRow(tb, 0)
tlp.SetColumn(p, 0)
tlp.SetRow(p, 1)
End Sub
End Class
That's certainly not wrong but it seems a bit of overkill to use a TableLayoutPanel for one control when you could achieve the same effect simply by setting properties of that control.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|