This is a migrated thread and some comments may be shown as answers.

IReadOnly not working

5 Answers 83 Views
RichTextBox (obsolete as of Q3 2014 SP1)
This is a migrated thread and some comments may be shown as answers.
Amin
Top achievements
Rank 1
Amin asked on 04 Feb 2012, 11:31 PM
Hi,

I used the code hereunder.
I need to make my Radrichtextbox read only therefore is used the Ireadonly property.
Problem is that when I click inside the Radrichtextbox, and the Delete key is pressed, text is removed.
If I press the Backspace key, nothing happens, correctly so.
If I press any other key, nothing happens, correctly so.
The problem therefore appears to relate to the Delete key only.

Anything I could be doing wrong, or is this a bug?
If it is a bug, is there any work-around?

Many thanks.


Me.RadRichTextBox1.Document = New RadDocument()
Dim provider As New HtmlFormatProvider()
Me.RadRichTextBox1.Document = provider.Import(Me.DataSetBindingSource.Current("TEXT2")) 'html from database
Me.RadRichTextBox1.Document.CaretPosition.MoveToFirstPositionInDocument()
Me.RadRichTextBox1.IsReadOnly = True

5 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 08 Feb 2012, 04:26 PM
Hello Amin,

Thank you for writing.

I can confirm that this is an issue with RadRichTextBox. I have logged this issue in our PITS system and we will address it in a future release. Here is a link, where you can add your vote for it: http://www.telerik.com/support/pits.aspx#/public/winforms/9643. What I can offer as work around is to detect when Delete key is pressed and call the Undo function of the editor:
Private Sub RadRichTextBox1_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles RadRichTextBox1.KeyDown
       If e.KeyData = Keys.Delete Then
           RadRichTextBox1.Undo()
       End If
   End Sub

I hope that you find this information helpful. Should you have any other questions, do not hesitate to contact us.
 
All the best,
Stefan
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Brennan
Top achievements
Rank 1
answered on 09 Feb 2012, 12:08 AM
Hello,

Further to this issue, how come the caret shows when the RichTextBox is read only?  This is confusing to users as they see the caret and expect to be able to type.  Is there any way to force the caret to hide when the RichtextBox is read only?

Thanks.

EDIT:

Further to the solution above "Undoing" the delete key press, the if statement should also check to see if the textbox is readonly before doing this as well:

If e.KeyData = Windows.Forms.Keys.Delete AndAlso sender.IsReadOnly Then
   sender.Undo()
End If
0
Stefan
Telerik team
answered on 09 Feb 2012, 12:09 PM
Hello Amin,

Thank you for the additional details. 

You can hide the caret by setting its Width to 0:
RadRichTextBox1.DocumentView.Caret.Width = 0

In regards to the check if the editor is in read only mode while undo, yes, such a check should be introduced if you use your editor in a non read-only mode too.

I hope this help.
 
Kind regards,
Stefan
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Michael Hilgers
Top achievements
Rank 1
answered on 30 Nov 2012, 02:51 PM
Is the "isReadOnly" Issue still not fixed in Q3 2012? Just installed in in the hope that isReadOnly = true really means that the field is read-only, but it is still writable .... :(

Regards,
Michael
0
Stefan
Telerik team
answered on 05 Dec 2012, 12:34 PM
Hello Michael, 

The IsReadOnly mode of the control works correctly on my end and deleting is no longer possible. If you continue experiencing this issue, please get back to us with the exact scenario how it can be reproduced and we will be glad to look into it.

Greetings,
Stefan
the Telerik team
Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
Tags
RichTextBox (obsolete as of Q3 2014 SP1)
Asked by
Amin
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Brennan
Top achievements
Rank 1
Michael Hilgers
Top achievements
Rank 1
Share this question
or