次の方法で共有


方法 : TextBox コントロールのテキスト コンテンツを設定する

この例では、Text プロパティを使用して、TextBox コントロールの初期のテキスト コンテンツを設定する方法を示します。

メモ    この例の Extensible Application Markup Language (XAML) バージョンでは、各ボタンの TextBox コンテンツのテキストの前後に <TextBox.Text> タグを使用することもできますが、TextBoxText プロパティに ContentPropertyAttribute 属性を適用するため、この処理は必要ありません。 詳細については、「XAML の概要 (WPF)」を参照してください。

使用例

<TextBox Name="tbSettingText">
  Initial text contents of the TextBox.
</TextBox>
tbSettingText.Text = "Initial text contents of the TextBox."
tbSettingText.Text = "Initial text contents of the TextBox.";

参照

概念

TextBox の概要

RichTextBox の概要