The Multi-Line Text Box |
|
Introduction |
The regular text box is meant to display a piece, or one line, of text. If the user enters text and presses Enter, nothing particular happens. If the user enters text and presses Tab, the focus moves to the next control in the tab sequence. You may want to create an application that goes further than the one-line limit. For example, if you have used Notepad, you would know that it shares the font characteristics of a text box but it also allows some text navigation features that require more than one line. You can create such an application based on the text box control. |
The TextBox control is equipped with one particular property that, when considered, changes the control tremendously. This property is called Multiline. Multiline is a Boolean property whose default value is false. If it is set to a true value, it allows the control to display multiple lines of text, unlike the normal text box that can display only one line. Here is an example: Imports System.Drawing Imports System.Windows.Forms Module Exercise Public Class Starter Inherits Form Private txtMemo As TextBox Dim components As System.ComponentModel.Container Public Sub New() InitializeComponent() End Sub Public Sub InitializeComponent() Text = "Memorandum" txtMemo = New TextBox txtMemo.Location = New Point(10, 10) txtMemo.Width = Width - 30 txtMemo.Height = Height - 50 txtMemo.Anchor = AnchorStyles.Left Or _ AnchorStyles.Top Or _ AnchorStyles.Right Or _ AnchorStyles.Bottom txtMemo.Multiline = True Controls.Add(txtMemo) End Sub End Class Function Main() As Integer Dim frmStart As Starter = New Starter Application.Run(frmStart) Return 0 End Function End Module This would produce:
|
|
||
Home | Copyright © 2008-2016, FunctionX, Inc. | Next |
|