This is a multi-part message in MIME format.

------=_NextPart_000_000C_01C47E22.F0198A50
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi, friends: =20

Do you know how to lock some of text in RichTextBox? Because I don't =
want user to change what other people have already wriiten in the =
RichTextBox.

Thanks,

Dennis Huang
------=_NextPart_000_000C_01C47E22.F0198A50
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1400" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2>Hi, friends:&nbsp; </FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Do you know how to lock some of text in <FONT=20
size=3D2>RichTextBox? Because I don't want user to change what other =
people have=20
already wriiten in the RichTextBox.</FONT></FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Thanks,</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Dennis Huang</FONT></DIV></BODY></HTML>

------=_NextPart_000_000C_01C47E22.F0198A50--

RE: Lock part of text in RichTextBox by Ben

Ben
Mon Aug 09 00:35:01 CDT 2004

Set the ReadOnly property to true... That should do the trick.

Ben

"BVM" wrote:

> Hi, friends:
>
> Do you know how to lock some of text in RichTextBox? Because I don't want user to change what other people have already wriiten in the RichTextBox.
>
> Thanks,
>
> Dennis Huang

Re: Lock part of text in RichTextBox by Morten

Morten
Mon Aug 09 01:04:28 CDT 2004

Hi Dennis,

Use the SelectionProtected property to mark text protected.
This sample will select all text in the richTextBox and mark it as protected.
The user can add more text, but cannot change the protected text.

richTextBox1.Text = "Hello World, this is a protected sentence.\n";
richTextBox1.SelectAll();
richTextBox1.SelectionColor = Color.Red;
richTextBox1.SelectionProtected = true;
richTextBox1.SelectionLength = 0;
richTextBox1.SelectionStart = richTextBox1.TextLength+1;

It also changes the protected text to red.
Note that you cannot change the text programmatically either until you unprotect the text.

--
Happy coding!
Morten Wennevik [C# MVP]