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. textbox control with multi colored rows

textbox control with multi colored rows

Scheduled Pinned Locked Moved C#
help
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.
  • G Offline
    G Offline
    gmahesh
    wrote on last edited by
    #1

    I wanted a multiline textbox control with possibility of giving different background colors to the lines. for eg:- if the first line has a white background the second line should have a yellow background etc. Please help

    A 1 Reply Last reply
    0
    • G gmahesh

      I wanted a multiline textbox control with possibility of giving different background colors to the lines. for eg:- if the first line has a white background the second line should have a yellow background etc. Please help

      A Offline
      A Offline
      Aryadip
      wrote on last edited by
      #2

      hi, The code below demonstrates one possible way of doing what you have requested... Label l1 = new Label(); l1.Text = "Hi there"; l1.Width = richTextBox1.Width; l1.Location = new Point(0,0); l1.BackColor = Color.AliceBlue; Label l2 = new Label(); l2.Width = richTextBox1.Width; l2.Location = new Point(0,l1.Bottom); l2.Text = "Howz life"; l2.BackColor = Color.Beige ; richTextBox1.Controls.Add(l1); richTextBox1.Controls.Add(l2); hope this helps you or atleast gives you an idea... this has what occured to me... regards, Aryadip. Cheers !! and have a Funky day !!

      G 1 Reply Last reply
      0
      • A Aryadip

        hi, The code below demonstrates one possible way of doing what you have requested... Label l1 = new Label(); l1.Text = "Hi there"; l1.Width = richTextBox1.Width; l1.Location = new Point(0,0); l1.BackColor = Color.AliceBlue; Label l2 = new Label(); l2.Width = richTextBox1.Width; l2.Location = new Point(0,l1.Bottom); l2.Text = "Howz life"; l2.BackColor = Color.Beige ; richTextBox1.Controls.Add(l1); richTextBox1.Controls.Add(l2); hope this helps you or atleast gives you an idea... this has what occured to me... regards, Aryadip. Cheers !! and have a Funky day !!

        G Offline
        G Offline
        gmahesh
        wrote on last edited by
        #3

        Hi, Thanks for that very good idea. What I want is also that this textbox should have editing capabilities also like a notepad. By doing the way you mentioned in the sample code, we might be able to edit/select only one line at a time. Thanks & Regards Mahesh

        L 1 Reply Last reply
        0
        • G gmahesh

          Hi, Thanks for that very good idea. What I want is also that this textbox should have editing capabilities also like a notepad. By doing the way you mentioned in the sample code, we might be able to edit/select only one line at a time. Thanks & Regards Mahesh

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          The best way to accomplish that, would be a RichtextBox. LokiSD wrote an article[^] on how to do Richtextbox background highlighting in Vb.Net. It would be worth looking into. What you would need to do, is find out the length of the line, and where the line starts. Set the selectionstart to the linestart, and selectionlength to the linelength. Then, call the function to highlight the selection color. Hope this gives you some idea's. Aaron Eldreth TheCollective4.com My Articles While much is too strange to be believed, Nothing is too strange to have happened. - T. Hardy

          G 1 Reply Last reply
          0
          • L Lost User

            The best way to accomplish that, would be a RichtextBox. LokiSD wrote an article[^] on how to do Richtextbox background highlighting in Vb.Net. It would be worth looking into. What you would need to do, is find out the length of the line, and where the line starts. Set the selectionstart to the linestart, and selectionlength to the linelength. Then, call the function to highlight the selection color. Hope this gives you some idea's. Aaron Eldreth TheCollective4.com My Articles While much is too strange to be believed, Nothing is too strange to have happened. - T. Hardy

            G Offline
            G Offline
            gmahesh
            wrote on last edited by
            #5

            Thanks a lot. That does the work for me.

            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