473,624 Members | 2,119 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

create bold,Italic Paragraph Tag...in Richtextbox

1 New Member
here i created sequence no. with every paragraph line

..

like...

<p local_id = P-100>aaaaaaaaaaa aaaaaaaaaaaaaa< \p>
<p local_id = P-101>bbbbbbbbbbb bbbbbbbbbbbbbb< \p>
<p local_id = P-102>vvvvvvvvvvv vvvvv<\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 + "\">">wwwwwwwww wwwww<\p>
<B local-id=\"B-" + p + "\">">aaaaaaaaa aaaa<\B>
<I local-id=\"I-" + p + "\">">yyyyyyyyy yyyyy<\I>

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

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

Similar topics

2
2423
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 selected text has to become bold, and if i click italic button, the bolded text has to become Italic too with the bolded attribute. how can i do this? help me.. thanks imaya kumar
6
27361
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 programatically and all works well, except for one thing: I don't seem to be able to make a paragraph apear in bold. I have tried: Selection.Font.Bold = wdToggle ' does not work I have tried: Selection.Font.Weight = 700 ' does not work I have tried:...
2
2860
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 change the selected text to bold, italic or underlined without using the font dialog?
2
2434
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, regular, italic...... Is there any code for this Thanks for any response
4
13352
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" but if i try this for bold and italic it doesn't work Dim f As New Font("Verdana", 30, FontStyle.Bold And FontStyle.Italic)
5
2600
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 documentations is excellent. This code looks to me like it should swap the bold highlight around, but Regular never gets reapplied, leaving both labels in Bold. Maybe there is a better way of doing this (aside from the obvious refactor), but...
1
3119
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 into HTML code. Replace the Bold text with <b>This is the bold text</bbefore I save it to an HTML file.
3
4298
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
8517
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 but doesn't foreach (DataGridViewCell cell in grid.SelectedCells) { cell.Style.Font = new Font(cell.Style.Font, FontStyle.Bold); } This does change it to bold but takes out italics and underline.
0
8234
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8172
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8677
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8620
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8474
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6110
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5563
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4174
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1784
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.