473,395 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

create bold,Italic Paragraph Tag...in Richtextbox

here i created sequence no. with every paragraph line

..

like...

<p local_id = P-100>aaaaaaaaaaaaaaaaaaaaaaaaa<\p>
<p local_id = P-101>bbbbbbbbbbbbbbbbbbbbbbbbb<\p>
<p local_id = P-102>vvvvvvvvvvvvvvvv<\p>



and show in richtextbox control..

here is my code:-

Expand|Select|Wrap|Line Numbers
  1. private void button1_Click(object sender, EventArgs e)
  2.         {
  3.             try
  4.             {
  5.                 OpenFileDialog ofd = new OpenFileDialog();
  6.                 //Font fonttext = null;
  7.  
  8.                 ofd.DefaultExt = "*rtf";
  9.                 ofd.Filter = "RTF File|*.rtf";
  10.                 ofd.ShowDialog();
  11.                 textBox1.Text = ofd.FileName.ToString();
  12.                 filepath = ofd.FileName.ToString();
  13.  
  14.                 //FileStream fs = new FileStream(filepath, FileMode.Open, FileAccess.Read);
  15.                 //StreamReader sr = new StreamReader(fs);
  16.  
  17.                 richTextBox1.LoadFile(filepath,RichTextBoxStreamType.RichText);
  18.                 string inputstring = richTextBox1.Text;
  19.                 StringBuilder sb = new StringBuilder(inputstring);
  20.                 //Font fonttext = new Font(sb);
  21.  
  22.                 //if (fonttext.Bold)
  23.                 //sb.Append(@"<B>");
  24.  
  25.                 //string xx = inputstring;
  26.                 //string yy = xx.Replace("", "");
  27.                 ////if (fonttext.Bold)
  28.                 ////    sb.Insert(0, "<B>");
  29.                 ////else if
  30.                 ////    (fonttext.Italic)
  31.                 ////    sb.Insert(0, "<I>");
  32.                 ////else
  33.  
  34.                 sb.Insert(0, "<p>");
  35.                 //string yy = xx.Replace("", "");
  36.                 //sb.Replace("<p>", "");
  37.                 //int num = 0;
  38.                 // sb.Replace("<p>"
  39.  
  40.                 sb.Replace("\n", "</p>" + "\n" + "<p>");
  41.                 sb.Replace("<p>" + "</p>", "");
  42.                 sb.Append("</p>");
  43.                 sb.Replace("<p>" + "</p>", "");
  44.                 sb.Replace("\n\n", "\n");
  45.                 sb.Replace("\n\n", "\n");
  46.                 sb.Replace("\n\n", "\n");
  47.                 sb.Replace("\n\n", "\n");
  48.                 sb.Replace("\n\n", "\n");
  49.                 sb.Replace("\n\n", "\n");
  50.                 int p=0;
  51.                 string xx = sb.ToString ();
  52.                 int ppara = 0;
  53.                 ppara = xx.IndexOf("<p>", 0);
  54.                 while (ppara!=  -1)
  55.                 {
  56.                     p = p+1;
  57.                     ////string f1 = Convert.ToString(p);
  58.                     //f1.ToString().PadLeft(8);
  59.                     xx = xx.Remove(ppara, 3);
  60.                     //if (fonttext.Bold)
  61.                     //    xx = xx.Insert(ppara, "<p local-id=\"B-" + p + "\">");
  62.                     //else
  63.                         xx = xx.Insert(ppara, "<p local-id=\"p-" + p + "\">");
  64.                     ppara = xx.IndexOf("<p>", ppara+3);
  65.                 }
  66.  
  67.                 richTextBox1.Text = xx.ToString();
  68.  
  69.             }
  70.            //}
  71.             catch (Exception ex)
  72.             {
  73.                 MessageBox.Show(ex.Message);
  74.             }
  75.         }

problem is that, if there is any bold,italic paragraph.then he show output in richtextbox like...
<p local-id=\"p-" + p + "\">">wwwwwwwwwwwwww<\p>
<B local-id=\"B-" + p + "\">">aaaaaaaaaaaaa<\B>
<I local-id=\"I-" + p + "\">">yyyyyyyyyyyyyy<\I>

then how??
Nov 8 '08 #1
0 2853

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Imaya Kumar | last post by:
Hi, i'm developing an editor in VS.NET using Rich Text Box Control. I need to make a selected text Bold. how can i do this? also i will have an Italic Button too. If i click Bold button the...
6
by: Ronny sigo | last post by:
Hello all, I have made a form with a lot of entryfields and one button which, when clicked on, transforms all of the entryfields values into a MS Word document. All the formatting is done...
2
by: Adam Honek | last post by:
Okay, Assinging the font and its style (bold, italic etc.) using the font dialog is easy such as: FontDialog1.ShowDialog() txtEmailBody.SelectionFont = FontDialog1.Font But how does one...
2
by: andreas | last post by:
When I select a text in a richtextbox to set de selected text in bold, regular, italic .. or non I want to do that with one click Thus I must find out if the selected text is already in bold,...
4
by: paraidy | last post by:
Hi, i'm using a richtextbox named r1, and i want to write in Bold and italic, i tryed this for bold and it work Dim f As New Font("Verdana", 30, FontStyle.Bold) r1.Font = f r1.Text = "Hello" ...
5
by: fidtz | last post by:
Sorry for asking here, but I don't know enough dotnet or Windows programming yet to be very good at googling for answers. OTOH, this is the first question I haven't be able to resolve myself, the...
1
by: Tor Inge Rislaa | last post by:
Finding Bold Text (or other formatting attributes) in RichTextbox . Is it possible to find and select bold text by code within the text of a RichTextbox? What I want is to manipulate the text...
3
by: sudhivns | last post by:
Hi, following is the part of my xml file. data.xml <Value> This is normal text This has to be printed in bold. This has to be printed in Italic. This has to be printed in bold/italic.
1
by: gmcconville | last post by:
Im a little bit stuck on how to change a cell in a datagridview to bold without affecting any of the other attributes of the cell, such as underline, italic etc. This is what I thought would work...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.