Control.Text プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

<LocalizableAttribute(True)> _ <BindableAttribute(True)> _ Public Overridable Property Text As String
[LocalizableAttribute(true)] [BindableAttribute(true)] public: virtual property String^ Text { String^ get (); void set (String^ value); }
このコントロールに関連付けられたテキスト。

コントロールの Text プロパティは、各派生クラスで異なった使われ方をします。たとえば、Form の Text プロパティは、フォームの上部のタイトル バーに表示され、少ない文字数で、通常はアプリケーション名またはドキュメント名を表示します。ただし、RichTextBox の Text プロパティは大きくすることができ、テキストの書式設定に使用される表示されない文字を多数含むことができます。たとえば、Font プロパティを調整したり、スペースまたはタブ文字を追加してテキストを揃えたりすることによって、RichTextBox に表示されるテキストを書式設定できます。
継承時の注意 派生クラスで Text プロパティをオーバーライドする場合は、基本クラスの Text プロパティを使用して、基本の実装を拡張します。それ以外の場合は、すべての実装を提供する必要があります。Text プロパティの get アクセサと set アクセサの両方をオーバーライドする必要はありません。必要に応じて 1 つのアクセサだけをオーバーライドできます。
GroupBox を作成して、共通プロパティの一部を設定するコード例を次に示します。この例では、TextBox を作成し、グループ ボックス内での Location を設定しています。次に、グループ ボックスの Text プロパティを設定して、グループ ボックスをフォームの上部にドッキングします。最後に、Enabled プロパティを false に設定してグループを無効にします。これにより、グループ ボックスに含まれるすべてのコントロールが無効になります。
' Add a GroupBox to a form and set some of its common properties. Private Sub AddMyGroupBox() ' Create a GroupBox and add a TextBox to it. Dim groupBox1 As New GroupBox() Dim textBox1 As New TextBox() textBox1.Location = New Point(15, 15) groupBox1.Controls.Add(textBox1) ' Set the Text and Dock properties of the GroupBox. groupBox1.Text = "MyGroupBox" groupBox1.Dock = DockStyle.Top ' Disable the GroupBox (which disables all its child controls) groupBox1.Enabled = False ' Add the Groupbox to the form. Me.Controls.Add(groupBox1) End Sub
// Add a GroupBox to a form and set some of its common properties. private void AddMyGroupBox() { // Create a GroupBox and add a TextBox to it. GroupBox groupBox1 = new GroupBox(); TextBox textBox1 = new TextBox(); textBox1.Location = new Point(15, 15); groupBox1.Controls.Add(textBox1); // Set the Text and Dock properties of the GroupBox. groupBox1.Text = "MyGroupBox"; groupBox1.Dock = DockStyle.Top; // Disable the GroupBox (which disables all its child controls) groupBox1.Enabled = false; // Add the Groupbox to the form. this.Controls.Add(groupBox1); }
// Add a GroupBox to a form and set some of its common properties. private: void AddMyGroupBox() { // Create a GroupBox and add a TextBox to it. GroupBox^ groupBox1 = gcnew GroupBox; TextBox^ textBox1 = gcnew TextBox; textBox1->Location = Point(15,15); groupBox1->Controls->Add( textBox1 ); // Set the Text and Dock properties of the GroupBox. groupBox1->Text = "MyGroupBox"; groupBox1->Dock = DockStyle::Top; // Disable the GroupBox (which disables all its child controls) groupBox1->Enabled = false; // Add the Groupbox to the form. this->Controls->Add( groupBox1 ); }
// Add a GroupBox to a form and set some of its common properties. private void AddMyGroupBox() { // Create a GroupBox and add a TextBox to it. GroupBox groupBox1 = new GroupBox(); TextBox textBox1 = new TextBox(); textBox1.set_Location(new Point(15, 15)); groupBox1.get_Controls().Add(textBox1); // Set the Text and Dock properties of the GroupBox. groupBox1.set_Text("MyGroupBox"); groupBox1.set_Dock(DockStyle.Top); // Disable the GroupBox (which disables all its child controls) groupBox1.set_Enabled(false); // Add the Groupbox to the form. this.get_Controls().Add(groupBox1); } //AddMyGroupBox

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からControl.Text プロパティを検索する場合は、下記のリンクをクリックしてください。

- Control.Text プロパティのページへのリンク