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

Dim instance As RichTextBox Dim value As Boolean value = instance.SelectionProtected instance.SelectionProtected = value
/** @property */ public boolean get_SelectionProtected () /** @property */ public void set_SelectionProtected (boolean value)
public function get SelectionProtected () : boolean public function set SelectionProtected (value : boolean)
現在の選択内容に対して変更を行うことができない場合は true。それ以外の場合は false。既定値は false です。

テキストが現在選択されていない場合、テキスト保護の設定は、カーソルがある段落と、カーソル位置以降にコントロールに入力されるすべてのテキストに適用されます。プロパティの値が変更されるまで、またはカーソル位置をコントロール内の別の段落に移動するまでの間は、このテキスト保護の設定が適用されます。
コントロール内でテキストが選択されている場合は、選択されているテキスト、およびテキストを選択した後に入力したすべてのテキストに対して、このプロパティの値が適用されます。このプロパティを使用して、コントロール内のテキスト部分をユーザーが変更できないように設定できます。
このプロパティが true に設定されている場合、現在選択されているテキストをユーザーが変更しようとすると Protected イベントが発生します。
![]() |
---|

SelectionProtected プロパティを使用して、RichTextBox 内で保護されるテキストを指定する方法を次のコード例に示します。この例では、richTextBox1 という名前の RichTextBox コントロールがフォームに追加されており、その RichTextBox コントロールに "RichTextBox" という単語が含まれるテキストが追加されている必要があります。
Private Sub ProtectMySelectedText() ' Determine if the selected text in the control contains the word "RichTextBox". If richTextBox1.SelectedText <> "RichTextBox" Then ' Search for the word RichTextBox in the control. If richTextBox1.Find("RichTextBox", RichTextBoxFinds.WholeWord) = -1 Then 'Alert the user that the word was not foun and return. MessageBox.Show("The text ""RichTextBox"" was not found!") Return End If End If ' Protect the selected text in the control from being altered. richTextBox1.SelectionProtected = True End Sub
private void ProtectMySelectedText() { // Determine if the selected text in the control contains the word "RichTextBox". if(richTextBox1.SelectedText != "RichTextBox") { // Search for the word RichTextBox in the control. if(richTextBox1.Find("RichTextBox",RichTextBoxFinds.WholeWord)== -1) { //Alert the user that the word was not foun and return. MessageBox.Show("The text \"RichTextBox\" was not found!"); return; } } // Protect the selected text in the control from being altered. richTextBox1.SelectionProtected = true; }
private: void ProtectMySelectedText() { // Determine if the selected text in the control contains the word "RichTextBox". if ( !richTextBox1->SelectedText->Equals( "RichTextBox" ) ) { // Search for the word RichTextBox in the control. if ( richTextBox1->Find( "RichTextBox", RichTextBoxFinds::WholeWord ) == -1 ) { //Alert the user that the word was not foun and return. MessageBox::Show( "The text \"RichTextBox\" was not found!" ); return; } } // Protect the selected text in the control from being altered. richTextBox1->SelectionProtected = true; }
private void ProtectMySelectedText() { // Determine if the selected text in the control contains the word //"RichTextBox". if (richTextBox1.get_SelectedText().Equals("RichTextBox")) { // Search for the word RichTextBox in the control. if (richTextBox1.Find("RichTextBox", RichTextBoxFinds.WholeWord) == -1) { //Alert the user that the word was not foun and return. MessageBox.Show("The text \"RichTextBox\" was not found!"); return; } } // Protect the selected text in the control from being altered. richTextBox1.set_SelectionProtected(true); } //ProtectMySelectedText

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に収録されているすべての辞書からRichTextBox.SelectionProtected プロパティを検索する場合は、下記のリンクをクリックしてください。

- RichTextBox.SelectionProtected プロパティのページへのリンク