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. C#
  4. replace richtextbox control

replace richtextbox control

Scheduled Pinned Locked Moved C#
questioncom
5 Posts 3 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.
  • L Offline
    L Offline
    Latheesan
    wrote on last edited by
    #1

    Hello, i came across this interesting article - http://www.codeproject.com/cs/miscctrl/SyntaxHighlighting.asp[^] The article provides it's own rtb, control, so i was wondering, how do you replace my own rtb controls with the one provided in this article? I already have a richtextbox on my form which i'd like to keep (because i build my application around that rtb), whilst using the controls provided by this article (for the syntax highlighting feature), how can i do this? I am not asking for someone to write me a code or full detailed explaination, a quick instruction would be much appreciated. Many thanks in advance for your input.

    D 1 Reply Last reply
    0
    • L Latheesan

      Hello, i came across this interesting article - http://www.codeproject.com/cs/miscctrl/SyntaxHighlighting.asp[^] The article provides it's own rtb, control, so i was wondering, how do you replace my own rtb controls with the one provided in this article? I already have a richtextbox on my form which i'd like to keep (because i build my application around that rtb), whilst using the controls provided by this article (for the syntax highlighting feature), how can i do this? I am not asking for someone to write me a code or full detailed explaination, a quick instruction would be much appreciated. Many thanks in advance for your input.

      D Offline
      D Offline
      Dan Neely
      wrote on last edited by
      #2

      assuming the replacement kept the same interface as the stock RTB, add the new control into your project's references, add it into the forms includes. replace the type and instantiation of the old RTB with those of the new control. IF the events and properties were changed you'll have to modify your existing code to work with the new interface.

      -- CleaKO The sad part about this instance is that none of the users ever said anything [about the problem]. Pete O`Hanlon Doesn't that just tell you everything you need to know about users?

      L 1 Reply Last reply
      0
      • D Dan Neely

        assuming the replacement kept the same interface as the stock RTB, add the new control into your project's references, add it into the forms includes. replace the type and instantiation of the old RTB with those of the new control. IF the events and properties were changed you'll have to modify your existing code to work with the new interface.

        -- CleaKO The sad part about this instance is that none of the users ever said anything [about the problem]. Pete O`Hanlon Doesn't that just tell you everything you need to know about users?

        L Offline
        L Offline
        Latheesan
        wrote on last edited by
        #3

        Im not good at C# at all, so i'll try to explain this as clear as possible (from my point of view). On the sample app provided in the article, it has a form without any rtb in it. BUT, the form us linked to an action form1_Load(); So, i had a look in there and this is the code i saw: SyntaxHighlightingTextBox shtb = new SyntaxHighlightingTextBox(); shtb.Location = new Point(0,0); shtb.Dock = DockStyle.Fill; shtb.Seperators.Add(' '); shtb.Seperators.Add('\r'); shtb.Seperators.Add('\n'); shtb.Seperators.Add(','); shtb.Seperators.Add('.'); shtb.Seperators.Add('-'); shtb.Seperators.Add('+'); //shtb.Seperators.Add('*'); //shtb.Seperators.Add('/'); Controls.Add(shtb); shtb.WordWrap = false; shtb.ScrollBars = RichTextBoxScrollBars.Both;// & RichTextBoxScrollBars.ForcedVertical; shtb.FilterAutoComplete = false; shtb.HighlightDescriptors.Add(new HighlightDescriptor("Hello", Color.Red, null, DescriptorType.Word, DescriptorRecognition.WholeWord, true)); As you can see, the class inside the syntax highlighting textbox library is called to make a new instance called "shtb" and then only after, words to highlight such as "hello" is added to it. My question orginally was, is it possible to have the ability to highlight text inside rtb (as i type), without creating a new instance such as "shtb", because i already have a rtb on my form. I just want to add the syntax highlighting functionality to the existing rtb box i have. Did i confuse you guys with what i am trying to achieve? Is this even possible?...:sigh:

        L 1 Reply Last reply
        0
        • L Latheesan

          Im not good at C# at all, so i'll try to explain this as clear as possible (from my point of view). On the sample app provided in the article, it has a form without any rtb in it. BUT, the form us linked to an action form1_Load(); So, i had a look in there and this is the code i saw: SyntaxHighlightingTextBox shtb = new SyntaxHighlightingTextBox(); shtb.Location = new Point(0,0); shtb.Dock = DockStyle.Fill; shtb.Seperators.Add(' '); shtb.Seperators.Add('\r'); shtb.Seperators.Add('\n'); shtb.Seperators.Add(','); shtb.Seperators.Add('.'); shtb.Seperators.Add('-'); shtb.Seperators.Add('+'); //shtb.Seperators.Add('*'); //shtb.Seperators.Add('/'); Controls.Add(shtb); shtb.WordWrap = false; shtb.ScrollBars = RichTextBoxScrollBars.Both;// & RichTextBoxScrollBars.ForcedVertical; shtb.FilterAutoComplete = false; shtb.HighlightDescriptors.Add(new HighlightDescriptor("Hello", Color.Red, null, DescriptorType.Word, DescriptorRecognition.WholeWord, true)); As you can see, the class inside the syntax highlighting textbox library is called to make a new instance called "shtb" and then only after, words to highlight such as "hello" is added to it. My question orginally was, is it possible to have the ability to highlight text inside rtb (as i type), without creating a new instance such as "shtb", because i already have a rtb on my form. I just want to add the syntax highlighting functionality to the existing rtb box i have. Did i confuse you guys with what i am trying to achieve? Is this even possible?...:sigh:

          L Offline
          L Offline
          Latheesan
          wrote on last edited by
          #4

          can anyone out there help me out on this please..?

          J 1 Reply Last reply
          0
          • L Latheesan

            can anyone out there help me out on this please..?

            J Offline
            J Offline
            jpg 0
            wrote on last edited by
            #5

            Spend some time to read the code from the article, learn how it works, then decide for yourself whether or not what you want is possible.

            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