Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Making some Text of RichTextBox Readonly

Making some Text of RichTextBox Readonly

Scheduled Pinned Locked Moved Visual Basic
help
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Het2109
    wrote on last edited by
    #1

    Hi, I want to make some of the Text of RichTextBox i have used in my project, readonly or non editable, can anyone please help me thanks :)Be Humble in Victory and Strong in Defeat.:) -Het

    R 1 Reply Last reply
    0
    • H Het2109

      Hi, I want to make some of the Text of RichTextBox i have used in my project, readonly or non editable, can anyone please help me thanks :)Be Humble in Victory and Strong in Defeat.:) -Het

      R Offline
      R Offline
      RichardGrimmer
      wrote on last edited by
      #2

      Try setting it's Enabled property to false... Can still set and get text through code, but the user can't do anything with it at runtime. "Now I guess I'll sit back and watch people misinterpret what I just said......" Christian Graus At The Soapbox

      H 1 Reply Last reply
      0
      • R RichardGrimmer

        Try setting it's Enabled property to false... Can still set and get text through code, but the user can't do anything with it at runtime. "Now I guess I'll sit back and watch people misinterpret what I just said......" Christian Graus At The Soapbox

        H Offline
        H Offline
        Het2109
        wrote on last edited by
        #3

        Yes thats what i want, i want to only make some text to be enabled false and user will not be able to edit it at runtime, rest all text he can edit and make changes. have got those text which are to be make readonly by highlighting it with different color no just have to make it non-editable. thanks :)Be Humble in Victory and Strong in Defeat.:) -Het

        D V 2 Replies Last reply
        0
        • H Het2109

          Yes thats what i want, i want to only make some text to be enabled false and user will not be able to edit it at runtime, rest all text he can edit and make changes. have got those text which are to be make readonly by highlighting it with different color no just have to make it non-editable. thanks :)Be Humble in Victory and Strong in Defeat.:) -Het

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          In that case, you'd have to derive a new RichTextBox control and supply your own code for tracking which sections of text are ReadOnly. With the current RTB control, this isn't possible. The problems I see are how your going to track the sections of text that are ReadOnly and where this information is going to be stored with the document. Another problem is that a user can simply open the entire document in WordPad and your ReadOnly information will no loner be ReadOnly. RageInTheMachine9532

          H 1 Reply Last reply
          0
          • D Dave Kreskowiak

            In that case, you'd have to derive a new RichTextBox control and supply your own code for tracking which sections of text are ReadOnly. With the current RTB control, this isn't possible. The problems I see are how your going to track the sections of text that are ReadOnly and where this information is going to be stored with the document. Another problem is that a user can simply open the entire document in WordPad and your ReadOnly information will no loner be ReadOnly. RageInTheMachine9532

            H Offline
            H Offline
            Het2109
            wrote on last edited by
            #5

            i already have those words which are to be enabled false, as they will be delimited by special characters which will not be used by the user when he will be writing that template in RichTextBox, other thing is i will b storing that file in database henceforth it will not be opened in any other editor except mine, then fields which i am making enabled false will be dragged from say listbox to the richtextbox. its just like mail merge sort of application, in MS.Word. i am not able to write the Readonly Property for RichTextBox. if i can get a start. thanks :)Be Humble in Victory and Strong in Defeat.:) -Het

            D 1 Reply Last reply
            0
            • H Het2109

              i already have those words which are to be enabled false, as they will be delimited by special characters which will not be used by the user when he will be writing that template in RichTextBox, other thing is i will b storing that file in database henceforth it will not be opened in any other editor except mine, then fields which i am making enabled false will be dragged from say listbox to the richtextbox. its just like mail merge sort of application, in MS.Word. i am not able to write the Readonly Property for RichTextBox. if i can get a start. thanks :)Be Humble in Victory and Strong in Defeat.:) -Het

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              The more I think about it ... You can't use the RichTextBox control for this. You'll have to write your own control, POSSIBLY inheriting from the RichTextBox control. Your going to have to supply your own code for determining exactly where the cursor is and when the cursor is in a ReadOnly field or not. You WILL essentially be writing your own editor control. I don't know of, and can't find, a control with the support your looking for, so it looks like you'll be writing it from scratch. RageInTheMachine9532

              1 Reply Last reply
              0
              • H Het2109

                Yes thats what i want, i want to only make some text to be enabled false and user will not be able to edit it at runtime, rest all text he can edit and make changes. have got those text which are to be make readonly by highlighting it with different color no just have to make it non-editable. thanks :)Be Humble in Victory and Strong in Defeat.:) -Het

                V Offline
                V Offline
                VBGuruWantabe
                wrote on last edited by
                #7

                If this "read only" text is a header or footer, you can use a borderless label to hold the non-editable text. You will have to parse the RTF file to extract the text but you must be doing that if you are highlighting it. The remaining text will go to the RichTextBox. The RichTextBox will also be borderless and both will be in a "frame" to make them appear as one. If "to err is human", programmers must be superhuman...

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups