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.lines problem

richtextbox.lines problem

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

    Hi, First of all I think it's important to point out that my goal here is to create the image of 1 line of vertically centered text like you would find in the windows 7 calculator. My thought was to make 2 lines in the richtextbox, and on the 2nd line I would put the text. However when I do this it just doesn't show. I have checked the font color and it's black. Also multiline is true. Here is my code. Maybe I am missing something.

    richTextBox1.Lines = new string[2];
    richTextBox1.Lines[1] = 111;

    The 111 never appears in the text box and the value of richTextBox1.Lines[1] never even changes.

    L D 2 Replies Last reply
    0
    • B bfis108137

      Hi, First of all I think it's important to point out that my goal here is to create the image of 1 line of vertically centered text like you would find in the windows 7 calculator. My thought was to make 2 lines in the richtextbox, and on the 2nd line I would put the text. However when I do this it just doesn't show. I have checked the font color and it's black. Also multiline is true. Here is my code. Maybe I am missing something.

      richTextBox1.Lines = new string[2];
      richTextBox1.Lines[1] = 111;

      The 111 never appears in the text box and the value of richTextBox1.Lines[1] never even changes.

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi,

      rtb2.Lines=new string\[\] { "line 1", "line 2", "line 3" };
      

      works just fine. You should work out the difference yourself! :)

      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


      I only read formatted code with indentation, so please use PRE tags for code snippets.


      I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).


      B 1 Reply Last reply
      0
      • L Luc Pattyn

        Hi,

        rtb2.Lines=new string\[\] { "line 1", "line 2", "line 3" };
        

        works just fine. You should work out the difference yourself! :)

        Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


        I only read formatted code with indentation, so please use PRE tags for code snippets.


        I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).


        B Offline
        B Offline
        bfis108137
        wrote on last edited by
        #3

        I changed it to the following code and it worked so I guess I would like to know who I can set the whole array but I can't change individual items within the Lines array. I didn't see that it was read only and anyways if it was it wouldn't compile. To me it doesn't make sense.

        richTextBox1.Lines = new string[2] { "", "111111" };

        L 1 Reply Last reply
        0
        • B bfis108137

          I changed it to the following code and it worked so I guess I would like to know who I can set the whole array but I can't change individual items within the Lines array. I didn't see that it was read only and anyways if it was it wouldn't compile. To me it doesn't make sense.

          richTextBox1.Lines = new string[2] { "", "111111" };

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          After reading the documentation (you should try that, they really make an effort to explain things), I come up with:

          rtb2.Lines=new string\[\] { "line 1", "line 2", "line 3" };
          string\[\] lines=rtb2.Lines;
          lines\[1\]="new line 2";
          rtb2.Lines=lines;
          

          and that works too. BTW: I'm not saying it is the most efficient way under all circumstances... :|

          Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


          I only read formatted code with indentation, so please use PRE tags for code snippets.


          I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).


          B 1 Reply Last reply
          0
          • L Luc Pattyn

            After reading the documentation (you should try that, they really make an effort to explain things), I come up with:

            rtb2.Lines=new string\[\] { "line 1", "line 2", "line 3" };
            string\[\] lines=rtb2.Lines;
            lines\[1\]="new line 2";
            rtb2.Lines=lines;
            

            and that works too. BTW: I'm not saying it is the most efficient way under all circumstances... :|

            Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


            I only read formatted code with indentation, so please use PRE tags for code snippets.


            I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).


            B Offline
            B Offline
            bfis108137
            wrote on last edited by
            #5

            so what is the most efficient way in your opinion?

            1 Reply Last reply
            0
            • B bfis108137

              Hi, First of all I think it's important to point out that my goal here is to create the image of 1 line of vertically centered text like you would find in the windows 7 calculator. My thought was to make 2 lines in the richtextbox, and on the 2nd line I would put the text. However when I do this it just doesn't show. I have checked the font color and it's black. Also multiline is true. Here is my code. Maybe I am missing something.

              richTextBox1.Lines = new string[2];
              richTextBox1.Lines[1] = 111;

              The 111 never appears in the text box and the value of richTextBox1.Lines[1] never even changes.

              D Offline
              D Offline
              Dr Walt Fair PE
              wrote on last edited by
              #6

              I wonder what the type of 111 might be?

              CQ de W5ALT

              Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software

              L 1 Reply Last reply
              0
              • D Dr Walt Fair PE

                I wonder what the type of 111 might be?

                CQ de W5ALT

                Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software

                L Offline
                L Offline
                Luc Pattyn
                wrote on last edited by
                #7

                Console.WriteLine(111.GetType().ToString()) gives System.Int32 Pretty obvious, I'd say. :)

                Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


                I only read formatted code with indentation, so please use PRE tags for code snippets.


                I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).


                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