473,385 Members | 1,873 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,385 software developers and data experts.

Quotations in RichTextBox

I'm having trouble reading quotations inside the richTextBox when a file is opened on to it. I've tried a couple different methods, most of them didn't compile. I came across one that does compile and supposedly it's suppose to work but it doesn't in my case.

I tried this code to see if it would recognize the quotations. For testing purpose I wanted to see if it would start the string from the quotation.

Expand|Select|Wrap|Line Numbers
  1. str = str->Substring(line->IndexOf("\""));
  2. richTextBox1->AppendText(str);
  3.  
Another attempt was also for testing purposes. I tried to replace the quotation with a word just to see if it would recognize it. Both of these codes compile without errors, but none of these statements recognize it.

Expand|Select|Wrap|Line Numbers
  1.  
  2. str = str->Replace(S"\"",S"Fast ");
  3. richTextBox1->AppendText(str);
  4.  
  5.  
Note: ( ) denotes characters inside richTextBox

One thing that I did notice is when I open a RTF file into the richTextBox, it seems like all the characters match with each other, by this I mean when I open the RTF file into the richTextBox, let's say the RTF File had a content of ("Car"), so after the RTF file is opened, I see ("Car") on the richTextBox. Afterwards, I physically type ("Car") into the richTextBox next to ("Car") that was opened from the RTF. The word Car looks exactly the same for both input and file. In the richTextBox you would see ("Car" "Car"). On the otherhand, for quotations they appear different, depending on the font, the quotation i type into the richTextBox looks different from that was opened form the RTF file. I don't know if that helps but it's an observation.

Is there a way I can resolve this issue so that my code would recognize the quotations from the RTF file?
Aug 24 '07 #1
1 1683
I found the solution. As long as you write the script file inside the program, then the quotations work. Here is the code that works.

Expand|Select|Wrap|Line Numbers
  1.  
  2.                         scriptString = richTextBox1->Text;
  3.             scriptReader = new StringReader(scriptString);
  4.  
  5.             String* delimStr = S" =\"):[]{}"; 
  6.             Char delimiter[] = delimStr->ToCharArray();
  7.             String* split[] = 0;
  8.             int nextChar = 0;
  9.             int whiteSpaceCount = 0;
  10.             String* line = "";
  11.             String* str;
  12.             String* space = S" ";
  13.  
  14.             //iterate over the string using the StringReader, printing each line. 
  15.             while(nextChar >= 0)
  16.             {    
  17.                 //reading line by line    
  18.                 line = scriptReader->ReadLine();
  19.                 //erase any whitespaces until you see the first character of the string
  20.                 line = line->TrimStart(NULL);
  21.  
  22.                 for (int x = 0; x <= line->Length; x++) 
  23.                 {
  24.                     split = line->Split(delimiter, x);                
  25. IEnumerator* myEnum = split->GetEnumerator();
  26.                     str = String::Join(space, split);
  27.  
  28.                     while (myEnum->MoveNext()) 
  29.                     {    
  30.                         String* s = __try_cast<String*>(myEnum->Current);
  31.                     }
  32.  
  33.                 }
  34.  
  35.                 str = str->Substring(line->IndexOf("\"") + 1); 
  36.  
  37.                 while(str->StartsWith(S" "))
  38.                 {
  39.                     whiteSpaceCount++;
  40.                     str = str->Substring(line->IndexOf("\"") + whiteSpaceCount);            
  41.                 }
  42.  
  43.                 whiteSpaceCount = 0; //reset the counter, this counter is for white spaces in between the first quotation and the first word inside the quotation just incase there is a space. 
  44.  
  45.  
  46.                 if(line->StartsWith("T1"))
  47.                 {
  48.                     top1->Text = str;
  49.                     defaultText(sender, e, top1);
  50.                 }
  51.  
  52.                 //check if there's any more lines
  53.                 nextChar = scriptReader->Peek();
  54.  
  55.  
  56.  
Aug 27 '07 #2

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

Similar topics

0
by: nouno | last post by:
I am trying to spell check a richtextbox. Through code (shown below) I save the contents of the richtextbox to a rtf file, open the rtf file in Word, spell check it, save it, and then load the ftf...
3
by: kangoo | last post by:
Hi, I'm trying to remove the last charater in a richTextBox. I though richTextBox.Text.Remove(richTextBox.Text.length-1, 1); would work, but it does nothing (eg richTextBox.Text += "some new...
12
by: M O J O | last post by:
Hi, If I inside a thread creates a RichTextBox and only use this inside the thread, will there be any thread problems? I need to convert between Text and RTF inside a thread. Thanks!! M...
2
by: JonnyT | last post by:
I searched high and low for an answer on how to auto scroll a richtextbox and now I finally have it. Since it took me a while to get a good efficient way of doing it that didn't require focus to...
0
by: Vincent | last post by:
Dear all, I have implemented a class to export the content of RichTextBox to image in WYSISYG mode so that line breaks on the screen are the same as exported. C# Code: public struct...
9
by: James Wong | last post by:
Hi, I use the RichTextBox in my program. It will use different language in this RichTextBox (chinese and english characters), and it set the "DualFont" and use different fonts. By the way, how...
3
by: michael sorens | last post by:
The documentation for the RichTextBox is sketchy at best. I want to do a very simple task but I cannot find information on this. I am using a RichTextBox as an output window. Some text I want to...
0
by: Vimalathithan | last post by:
I just developing a editor. I have provide the options like Bold, Italic, underlin, font change, font size change. These font options are keep in with one toolstripbutton. the toolstripbar keep...
4
by: bmerlover | last post by:
Hi, I need to read a script file and change the text on the buttons I set. I have the psuedocode in my head, but I'm having trouble putting that into code. I figured out how to seperate B1 from T1...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.