IReadOnly not working

6 posts, 0 answers
  1. Amin
    Amin avatar
    6 posts
    Member since:
    Feb 2012

    Posted 04 Feb 2012 Link to this post

    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

  2. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 08 Feb 2012 Link to this post

    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 >>
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Brennan
    Brennan avatar
    39 posts
    Member since:
    Sep 2010

    Posted 08 Feb 2012 Link to this post

    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
  5. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 09 Feb 2012 Link to this post

    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 >>
  6. Michael Hilgers
    Michael Hilgers avatar
    76 posts
    Member since:
    Apr 2010

    Posted 30 Nov 2012 Link to this post

    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
  7. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 05 Dec 2012 Link to this post

    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.
Back to Top
UI for WinForms is Visual Studio 2017 Ready