TextBoxBase クラス
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _ <ComVisibleAttribute(True)> _ Public MustInherit Class TextBoxBase Inherits Control
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] [ComVisibleAttribute(true)] public abstract class TextBoxBase : Control
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] [ComVisibleAttribute(true)] public ref class TextBoxBase abstract : public Control
このクラスは、TextBox および RichTextBox などのテキスト処理コントロールの中心的な機能を実装します。これらの機能には、テキストの選択、クリップボード機能、複数行テキスト コントロールのサポート、および多くのイベントが含まれます。
継承時の注意 通常、TextBoxBase から継承することはありません。独自のテキスト コントロール クラスを作成するには、TextBox または RichTextBox から継承します。派生クラス TextBox を使用して、垂直スクロール バーのある複数行 TextBox コントロールを作成するコード例を次に示します。この例では、AcceptsTab、AcceptsReturn、WordWrap の各プロパティも使用して、テキスト ドキュメントを作成しやすいように複数行テキスト ボックス コントロールを設定します。
Public Sub CreateMyMultilineTextBox() ' Create an instance of a TextBox control. Dim textBox1 As New TextBox() ' Set the Multiline property to true. textBox1.Multiline = True ' Add vertical scroll bars to the TextBox control. textBox1.ScrollBars = ScrollBars.Vertical ' Allow the RETURN key in the TextBox control. textBox1.AcceptsReturn = True ' Allow the TAB key to be entered in the TextBox control. textBox1.AcceptsTab = True ' Set WordWrap to true to allow text to wrap to the next line. textBox1.WordWrap = True ' Set the default text of the control. textBox1.Text = "Welcome!" & Environment.NewLine & "Second Line" End Sub
public void CreateMyMultilineTextBox() { // Create an instance of a TextBox control. TextBox textBox1 = new TextBox(); // Set the Multiline property to true. textBox1.Multiline = true; // Add vertical scroll bars to the TextBox control. textBox1.ScrollBars = ScrollBars.Vertical; // Allow the RETURN key in the TextBox control. textBox1.AcceptsReturn = true; // Allow the TAB key to be entered in the TextBox control. textBox1.AcceptsTab = true; // Set WordWrap to true to allow text to wrap to the next line. textBox1.WordWrap = true; // Set the default text of the control. textBox1.Text = "Welcome!" + Environment.NewLine + "Second Line"; }
public: void CreateMyMultilineTextBox() { // Create an instance of a TextBox control. TextBox^ textBox1 = gcnew TextBox; // Set the Multiline property to true. textBox1->Multiline = true; // Add vertical scroll bars to the TextBox control. textBox1->ScrollBars = ScrollBars::Vertical; // Allow the RETURN key in the TextBox control. textBox1->AcceptsReturn = true; // Allow the TAB key to be entered in the TextBox control. textBox1->AcceptsTab = true; // Set WordWrap to true to allow text to wrap to the next line. textBox1->WordWrap = true; // Set the default text of the control. textBox1->Text = "Welcome!" + Environment::NewLine + "Second Line"; }
public void CreateMyMultilineTextBox() { // Create an instance of a TextBox control. TextBox textBox1 = new TextBox(); // Set the Multiline property to true. textBox1.set_Multiline(true); // Add vertical scroll bars to the TextBox control. textBox1.set_ScrollBars(ScrollBars.Vertical); // Allow the RETURN key in the TextBox control. textBox1.set_AcceptsReturn(true); // Allow the TAB key to be entered in the TextBox control. textBox1.set_AcceptsTab(true); // Set WordWrap to true to allow text to wrap to the next line. textBox1.set_WordWrap(true); // Set the default text of the control. textBox1.set_Text("Welcome!" + Environment.get_NewLine() + "Second Line"); } //CreateMyMultilineTextBox
System.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.Control
System.Windows.Forms.TextBoxBase
System.Windows.Forms.MaskedTextBox
System.Windows.Forms.RichTextBox
System.Windows.Forms.TextBox
プラットフォーム
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
- TextBoxBase クラスのページへのリンク