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. RichTextBox: How to get the count of tabs in a TextLine

RichTextBox: How to get the count of tabs in a TextLine

Scheduled Pinned Locked Moved C#
helptutorialquestion
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
    STW
    wrote on last edited by
    #1

    I wrote a simple dBase Program Editor for Program Files. Now I wanted to add the following functionnality: IF X=0 DO XPRG ENDI ---> IF X=0 DO XPRG ENDI For this method I need the count of tabs in a line (because of reloading, when tabs already are set). The Problem is that Line.IndexOf("\t") does not return the right value (RichTextBox always find this value and never returns -1). So how is it possible to determine how much tabs are in a StringLine? Or is there another way to solve this problem? Thanks. Stefan

    D 1 Reply Last reply
    0
    • S STW

      I wrote a simple dBase Program Editor for Program Files. Now I wanted to add the following functionnality: IF X=0 DO XPRG ENDI ---> IF X=0 DO XPRG ENDI For this method I need the count of tabs in a line (because of reloading, when tabs already are set). The Problem is that Line.IndexOf("\t") does not return the right value (RichTextBox always find this value and never returns -1). So how is it possible to determine how much tabs are in a StringLine? Or is there another way to solve this problem? Thanks. Stefan

      D Offline
      D Offline
      dynamic
      wrote on last edited by
      #2

      C#:


      private void Form1_Load(object sender, System.EventArgs e)
      {
      richTextBox1.AppendText("some\ttext\twith\ttabs\tin\tthere"); /// 5 tabs in a line.
      }

      private void button1_Click(object sender, System.EventArgs e)
      {
      MessageBox.Show(richTextBox1.Lines[0].Split('\t').GetUpperBound(0).ToString()); // 0 is the first line in the richtextbox, upperbound is the count of tabs.
      }


      hope that helps :) Vb:


      Public Function TwinsOnWay(ByVal twins As String) As String
      Select Case twins
      Case "Gender"
      Return "Two Girls"
      End Select
      End Function


      S 1 Reply Last reply
      0
      • D dynamic

        C#:


        private void Form1_Load(object sender, System.EventArgs e)
        {
        richTextBox1.AppendText("some\ttext\twith\ttabs\tin\tthere"); /// 5 tabs in a line.
        }

        private void button1_Click(object sender, System.EventArgs e)
        {
        MessageBox.Show(richTextBox1.Lines[0].Split('\t').GetUpperBound(0).ToString()); // 0 is the first line in the richtextbox, upperbound is the count of tabs.
        }


        hope that helps :) Vb:


        Public Function TwinsOnWay(ByVal twins As String) As String
        Select Case twins
        Case "Gender"
        Return "Two Girls"
        End Select
        End Function


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

        Thanks a lot for this idea! Stefan

        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