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. how to make what SelectionIndent does in tabs

how to make what SelectionIndent does in tabs

Scheduled Pinned Locked Moved C#
tutorialquestion
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.
  • E Offline
    E Offline
    ektoras
    wrote on last edited by
    #1

    Could I have an example how to make what richTextBox1.SelectionIndent does but measuring in tabs instead of pixels ? (I want to insert tabs in front of certain lines)

    H 1 Reply Last reply
    0
    • E ektoras

      Could I have an example how to make what richTextBox1.SelectionIndent does but measuring in tabs instead of pixels ? (I want to insert tabs in front of certain lines)

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      Tabs are characters. If you need to set a "tab" as Word denotes it, the RichTextBox.SelectIndent is the correct way. This changes the indentation of a paragraph but does not use a tab character, for changes in that paragraph would require a fairly complex algorithm to go and reposition tab characters. What you should do is get the Font of the currently selected paragraph (using RichTextBox.SelectionFont), the do something like this:

      Graphics g = CreateGraphics();
      SizeF size = g.MeasureString("\t", richTextBox1.SelectionFont);
      int indentation = (int)size.Width;
      richTextBox1.SelectionIndent = indentation;

      This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles] [My Blog]

      E 1 Reply Last reply
      0
      • H Heath Stewart

        Tabs are characters. If you need to set a "tab" as Word denotes it, the RichTextBox.SelectIndent is the correct way. This changes the indentation of a paragraph but does not use a tab character, for changes in that paragraph would require a fairly complex algorithm to go and reposition tab characters. What you should do is get the Font of the currently selected paragraph (using RichTextBox.SelectionFont), the do something like this:

        Graphics g = CreateGraphics();
        SizeF size = g.MeasureString("\t", richTextBox1.SelectionFont);
        int indentation = (int)size.Width;
        richTextBox1.SelectionIndent = indentation;

        This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles] [My Blog]

        E Offline
        E Offline
        ektoras
        wrote on last edited by
        #3

        Thank you Heath Stewart

        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