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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. how to use formating in richtextbox..

how to use formating in richtextbox..

Scheduled Pinned Locked Moved C#
helptutorialquestionlounge
5 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.
  • R Offline
    R Offline
    raj231362
    wrote on last edited by
    #1

    hello all, actually i am working on richtextbox control in window application. i have a problem in font class. because i want to show rtf file paragraph in para for

    <\p>, for bold paragrpah**<\b>, For ITalic Paragrph_,<\I>. so, how here i am use font class to generate such tag with every paragrph. my code is here,plz help me ...??? richTextBox1.LoadFile(filepath,RichTextBoxStreamType.RichText); string inputstring = richTextBox1.Text; StringBuilder sb =newStringBuilder(inputstring); //string xx = inputstring; //string yy = xx.Replace("", ""); sb.Insert(0, "<p>"); //string yy = xx.Replace("", ""); //sb.Replace("<p>", ""); //int num = 0; // sb.Replace("<p>" //Random rand = new Random(3); string rt = "" ; for (int i = 0; i < 10; i++) { rt = i.ToString(); } //sb.Insert(0, "<p local_id = P-" + rt + ">"); sb.Replace("\n", "</p>" + "\n" + "<p>"); //sb.Replace("<p local_id = P-" + rt + ">" +"</p>", ""); //sb.Append("</p>"); //sb.Replace("<p local_id = P-" + rt + ">" + "</p>", ""); sb.Replace("\n\n", "\n"); sb.Replace("\n\n", "\n"); sb.Replace("\n\n", "\n"); sb.Replace("\n\n", "\n"); sb.Replace("\n\n", "\n"); sb.Replace("\n\n", "\n"); int p=0; string xx = sb.ToString (); int ppara = 0; ppara = xx.IndexOf("<p>", 0); while (ppara!= -1) { p = p+1; string f1 = Convert.ToString(p); f1.ToString().PadLeft(3); xx = xx.Remove(ppara, 3); xx = xx.Insert(ppara, "<p local-id=\"p-" + p + "\">"); ppara = xx.IndexOf("<p>", ppara+3); } richTextBox1.Text = xx.ToString(); } //} catch (Exception ex) { MessageBox.Show(ex.Message); } }_**

    S 1 Reply Last reply
    0
    • R raj231362

      hello all, actually i am working on richtextbox control in window application. i have a problem in font class. because i want to show rtf file paragraph in para for

      <\p>, for bold paragrpah**<\b>, For ITalic Paragrph_,<\I>. so, how here i am use font class to generate such tag with every paragrph. my code is here,plz help me ...??? richTextBox1.LoadFile(filepath,RichTextBoxStreamType.RichText); string inputstring = richTextBox1.Text; StringBuilder sb =newStringBuilder(inputstring); //string xx = inputstring; //string yy = xx.Replace("", ""); sb.Insert(0, "<p>"); //string yy = xx.Replace("", ""); //sb.Replace("<p>", ""); //int num = 0; // sb.Replace("<p>" //Random rand = new Random(3); string rt = "" ; for (int i = 0; i < 10; i++) { rt = i.ToString(); } //sb.Insert(0, "<p local_id = P-" + rt + ">"); sb.Replace("\n", "</p>" + "\n" + "<p>"); //sb.Replace("<p local_id = P-" + rt + ">" +"</p>", ""); //sb.Append("</p>"); //sb.Replace("<p local_id = P-" + rt + ">" + "</p>", ""); sb.Replace("\n\n", "\n"); sb.Replace("\n\n", "\n"); sb.Replace("\n\n", "\n"); sb.Replace("\n\n", "\n"); sb.Replace("\n\n", "\n"); sb.Replace("\n\n", "\n"); int p=0; string xx = sb.ToString (); int ppara = 0; ppara = xx.IndexOf("<p>", 0); while (ppara!= -1) { p = p+1; string f1 = Convert.ToString(p); f1.ToString().PadLeft(3); xx = xx.Remove(ppara, 3); xx = xx.Insert(ppara, "<p local-id=\"p-" + p + "\">"); ppara = xx.IndexOf("<p>", ppara+3); } richTextBox1.Text = xx.ToString(); } //} catch (Exception ex) { MessageBox.Show(ex.Message); } }_**

      S Offline
      S Offline
      sph3rex
      wrote on last edited by
      #2

      use RichTextBox.Select(int start, int lengthofselection) and then apply the style you want to selection using RichTextBox.SelectionFont property

      R 1 Reply Last reply
      0
      • S sph3rex

        use RichTextBox.Select(int start, int lengthofselection) and then apply the style you want to selection using RichTextBox.SelectionFont property

        R Offline
        R Offline
        raj231362
        wrote on last edited by
        #3

        thanks for ur warm response... when applied this its not working prperly... code is:- while (ppara <= xx.Length) { int postspace = xx.IndexOf("", 0); if (postspace != -1) { string word = xx.Substring(x, postspace); richText.Select(x, postspace); richTextBox1.SelectionFont.Bold; xx = xx.Insert(ppara, "

        "); } } help me for code.....

        S 1 Reply Last reply
        0
        • R raj231362

          thanks for ur warm response... when applied this its not working prperly... code is:- while (ppara <= xx.Length) { int postspace = xx.IndexOf("", 0); if (postspace != -1) { string word = xx.Substring(x, postspace); richText.Select(x, postspace); richTextBox1.SelectionFont.Bold; xx = xx.Insert(ppara, "

          "); } } help me for code.....

          S Offline
          S Offline
          sph3rex
          wrote on last edited by
          #4

          int postspace = xx.IndexOf("", 0); is equivalent to int postspace = xx.IndexOf(String.Empty, 0); which doesn't make too much sense ... if you're looking for the first occurence of a space use int postspace = xx.IndexOf(" ", 0);

          R 1 Reply Last reply
          0
          • S sph3rex

            int postspace = xx.IndexOf("", 0); is equivalent to int postspace = xx.IndexOf(String.Empty, 0); which doesn't make too much sense ... if you're looking for the first occurence of a space use int postspace = xx.IndexOf(" ", 0);

            R Offline
            R Offline
            raj231362
            wrote on last edited by
            #5

            hello, here i want to read every character while space. when new word come again then he read continue..if any character is bold and italic he show in richtextbox with sequence no... i am new in C# dot net.so plz provide me some specific code related 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