RichTextBox.SelectionProtected Eigenschap
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Hiermee wordt een waarde opgehaald of ingesteld die aangeeft of de huidige tekstselectie is beveiligd.
public:
property bool SelectionProtected { bool get(); void set(bool value); };
[System.ComponentModel.Browsable(false)]
public bool SelectionProtected { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.SelectionProtected : bool with get, set
Public Property SelectionProtected As Boolean
Waarde van eigenschap
true indien de huidige selectie wijzigingen in de inhoud voorkomt; anders, false. De standaardwaarde is false.
- Kenmerken
Voorbeelden
In het volgende codevoorbeeld ziet u hoe u beveiligde tekst in de RichTextBoxSelectionProtected eigenschap opgeeft. Dit voorbeeld vereist dat een RichTextBox besturingselement met de naam richTextBox1is toegevoegd aan het formulier en dat er tekst aan het RichTextBox besturingselement is toegevoegd die het woord 'RichTextBox' bevat.
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.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 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
Opmerkingen
Als er momenteel geen tekst is geselecteerd, wordt de beveiligingsinstelling toegepast op de alinea waarin de invoegpositie wordt weergegeven en op alle tekst die na de invoegpositie in het besturingselement is getypt. De beveiligingsinstelling is van toepassing totdat de eigenschap wordt gewijzigd in een andere waarde of totdat de invoegpositie wordt verplaatst naar een andere alinea in het besturingselement.
Als tekst in het besturingselement is geselecteerd, worden de geselecteerde tekst en alle tekst die na de tekstselectie is ingevoerd, de waarde van deze eigenschap toegepast. U kunt deze eigenschap gebruiken om te voorkomen dat de gebruiker secties van tekst binnen het besturingselement wijzigt.
Als deze eigenschap is ingesteld op true, wordt de Protected gebeurtenis gegenereerd wanneer de gebruiker de huidige tekstselectie probeert te wijzigen.
Note
Deze eigenschap wordt alleen geretourneerd true als de volledige selectie in het besturingselement beveiligde inhoud bevat.