RichTextBox.SelectionAlignment プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > RichTextBox.SelectionAlignment プロパティの意味・解説 

RichTextBox.SelectionAlignment プロパティ

現在選択されている内容またはカーソル位置適用される配置取得または設定します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Property SelectionAlignment As
 HorizontalAlignment
Dim instance As RichTextBox
Dim value As HorizontalAlignment

value = instance.SelectionAlignment

instance.SelectionAlignment = value
public HorizontalAlignment SelectionAlignment { get;
 set; }
public:
property HorizontalAlignment SelectionAlignment {
    HorizontalAlignment get ();
    void set (HorizontalAlignment value);
}
/** @property */
public HorizontalAlignment get_SelectionAlignment ()

/** @property */
public void set_SelectionAlignment (HorizontalAlignment
 value)
public function get SelectionAlignment
 () : HorizontalAlignment

public function set SelectionAlignment
 (value : HorizontalAlignment)

プロパティ
HorizontalAlignment 値の 1 つ

例外例外
例外種類条件

InvalidEnumArgumentException

指定した値が HorizontalAlignment クラス定義されている値ではありません。

解説解説

コントロール内で選択されている段落ない場合、このプロパティ設定した配置は、その設定適用されている段落の後に作成され段落だけでなく、カーソル挿入されている段落にも適用されます。たとえば、RichTextBox コントロール2 つ段落があり、カーソル2 番目の段落内にあるとしますSelectionAlignment プロパティHorizontalAlignment.Center設定すると、カーソル挿入されている段落コントロール中央揃えて配置されます。2 番目の段落の後に 3 番目の段落作成すると、3 番目の段落コントロール中央揃えて配置されます。

プロパティ設定するときにコントロール内で段落選択されている場合は、選択されているすべての段落が、このプロパティ設定基づいて配置されます。このプロパティ使用すると、RichTextBox作成中ドキュメント段落揃えることができます。たとえば、ドキュメント内のすべての段落中央揃えて配置する場合は、コントロール内のすべての段落選択しSelectionAlignment プロパティHorizontalAlignment.Center設定します

メモメモ

選択したテキストに、さまざまな配置混在し段落複数含まれている場合SelectionAlignmentSelectionAlignment.Left返します

使用例使用例

RichTextBox 内でテキスト配置する方法次のコード例示します。この例では、richTextBox1 という名前の RichTextBox コントロールフォーム追加されている必要があります

Private Sub WriteCenteredTextToRichTextBox()
   ' Clear all text from the RichTextBox;
   richTextBox1.Clear()
   ' Set the foreground color of the text.
   richTextBox1.SelectionColor = Color.Red
   ' Set the alignment of the text that follows.
   richTextBox1.SelectionAlignment = HorizontalAlignment.Center
   ' Set the font for the text.
   richTextBox1.SelectionFont = new Font("Lucinda
 Console", 12)
   ' Set the text within the control.
   richTextBox1.SelectedText = "This text is centered using the
 SelectionAlignment property."

End Sub
private void WriteCenteredTextToRichTextBox()
{
   // Clear all text from the RichTextBox;
   richTextBox1.Clear();
   // Set the foreground color of the text.
   richTextBox1.ForeColor = Color.Red;
   // Set the alignment of the text that follows.
   richTextBox1.SelectionAlignment = HorizontalAlignment.Center;
   // Set the font for the text.
   richTextBox1.SelectionFont = new Font("Lucinda Console",
 12);
   // Set the text within the control.
   richTextBox1.SelectedText = "This text is centered using
 the SelectionAlignment property.\n";
}
private:
   void WriteCenteredTextToRichTextBox()
   {
      // Clear all text from the RichTextBox;
      richTextBox1->Clear();

      // Set the foreground color of the text.
      richTextBox1->ForeColor = Color::Red;

      // Set the alignment of the text that follows.
      richTextBox1->SelectionAlignment = HorizontalAlignment::Center;

      // Set the font for the text.
      richTextBox1->SelectionFont = gcnew System::Drawing::Font( "Lucinda
 Console",12 );

      // Set the text within the control.
      richTextBox1->SelectedText = "This text is centered using
 the SelectionAlignment property.\n";
   }
private void WriteCenteredTextToRichTextBox()
{
    // Clear all text from the RichTextBox;
    richTextBox1.Clear();
    // Set the foreground color of the text.
    richTextBox1.set_ForeColor(Color.get_Red());
    // Set the alignment of the text that follows.
    richTextBox1.set_SelectionAlignment(HorizontalAlignment.Center);
    // Set the font for the text.
    richTextBox1.set_SelectionFont(new Font("Lucinda Console",
 12));
    // Set the text within the control.
    richTextBox1.set_SelectedText("This text is centered using
 the"
        + "SelectionAlignment property.\n");
} //WriteCenteredTextToRichTextBox
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
RichTextBox クラス
RichTextBox メンバ
System.Windows.Forms 名前空間
HorizontalAlignment 列挙


このページでは「.NET Framework クラス ライブラリ リファレンス」からRichTextBox.SelectionAlignment プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からRichTextBox.SelectionAlignment プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からRichTextBox.SelectionAlignment プロパティ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

RichTextBox.SelectionAlignment プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



RichTextBox.SelectionAlignment プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS