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. Adding Line Numbers to a text box?

Adding Line Numbers to a text box?

Scheduled Pinned Locked Moved C#
tutorialhelpquestion
3 Posts 2 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.
  • S Offline
    S Offline
    se99ts
    wrote on last edited by
    #1

    i would like to add line numbers to a richTextBox, does anyone know of an easy way of doing this? i was thinking about having two text boxes controlled by the same scroll bar but i dont know how to link them up? or is it easier to use a different control to add the line numbers? Any help would be extreemly useful as i dont remember seeing an example of this or anything similar anywhere!

    B 1 Reply Last reply
    0
    • S se99ts

      i would like to add line numbers to a richTextBox, does anyone know of an easy way of doing this? i was thinking about having two text boxes controlled by the same scroll bar but i dont know how to link them up? or is it easier to use a different control to add the line numbers? Any help would be extreemly useful as i dont remember seeing an example of this or anything similar anywhere!

      B Offline
      B Offline
      Brandon B
      wrote on last edited by
      #2

      I was thinking about how to design a custom control with the same functionality for the richTextBox. My initial approach would be to use a panel along the left side and set its dock property to left and the richTextBox to fill. I think there would have to be some sort of callback to the panel so it knows to update the line numbers. I do not know if this is the correct approach but it could be a start for further discussion on this topic. I would be interested in seeing the best method to do this. Regards, Brandon

      S 1 Reply Last reply
      0
      • B Brandon B

        I was thinking about how to design a custom control with the same functionality for the richTextBox. My initial approach would be to use a panel along the left side and set its dock property to left and the richTextBox to fill. I think there would have to be some sort of callback to the panel so it knows to update the line numbers. I do not know if this is the correct approach but it could be a start for further discussion on this topic. I would be interested in seeing the best method to do this. Regards, Brandon

        S Offline
        S Offline
        se99ts
        wrote on last edited by
        #3

        My only reason for thinking of using two of the same text controls was an easy way to keep line numbers in the correct place as they could both share the same font and would have equal spaces in the line numbering i thought it would then be a simple task to get them to scroll together and somehow lock the textbox displaying the numbers so that it wouldn't highlight or selct on click, it would just appear next to it.

        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