473,766 Members | 2,044 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Quotations in RichTextBox

50 New Member
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 1712
bmerlover
50 New Member
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
3250
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 file back into the ricktextbox using loadfile. The problem is that the richtextbox seems to remain bound to the rtf file. If I make a change in the richtextbox after spell checking, the changes are successfully saved to the database but if the...
3
21158
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 text"; works) Thanks for your attention & solutions
12
2186
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 O J O
2
17375
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 the control or the scrolltocaret method I decided that it would be worth posting to anyone who might have similar concerns. For the record this works well in an environment where you cannot have focus going to the richtextbox....such as a chat...
0
11158
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 STRUCT_RECT
9
4878
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 can I print out this content to printer easily? Thanks! James
3
7186
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 just add plain (e.g.. rtf.Text += "new stuff..."; ) but some text, when added, I want to be in a different color or font size. Find() will not work because the text will vary. I have delimiters on it so I could recognize it with a regular ...
0
2060
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 inside with panel. The RichTextBox keep inside with other panel. The panel height and width is same with RichTextBox. The RichTextBox both scrolling options are make it as false. I done the coding for RichTextBox's height to fit with...
4
1949
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 and etc. from each other. From there I haven't tried yet but I'm pretty sure I can change the text on the buttons. My question is how can I read what is inside the quotations and save that into a string. Well I can save that into a string as long as I...
0
9568
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
9404
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
10168
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
10008
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
8833
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7381
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
6651
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
5279
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.