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

RichTextBox.RTF not updating properly? Please help!!

Hello,

I have a little form that people can fill out to generate CD labels
from an RTF template. The template basically contains variables that
are replaced by the text typed into the form.

I also have a "Preview" tab which will show a RichTextBoxcontaining
the output of the label generator (ie. the template, with the
variables replaced).

I am able to load the template into a RichTextBox without problems.
This gives me a RichTextBox containing a CD label with words like
%MIDDLE-LEFT% and the other variables.

Then I have the code below, which replaces the text with whatever is
in the user-edited textboxes (eg. txtMiddleLeft.Text):

Expand|Select|Wrap|Line Numbers
  1. txt_Preview.Rtf = templateRTFText  // this works fine
  2. tmpVar = Replace(templateRTFText, "%MIDDLE-LEFT%",
  3. txtMiddleLeft.Text, , , CompareMethod.Text)  // this works fine
  4. txt_Preview.Rtf = "" // this works fine!
  5. txt_Preview.Rtf = tmpVar // this does not work!
  6.  
This does not work. The variable tmpVar ends up with the correct,
updated data (I checked by copying it to the clipboard and pasting it
into a new RTF file- the variables were replaced). But the
RichTextBox still contains the template text. If I copy
txt_Preview.Rtf to the clipboard, it still contains the template data.

No errors are generated when I run the last line. Can someone please
help me! How should I be accomplishing this?

Note that I am not using PrintPreviewDialog because I need this to
appear inside an existing tab, and I also have not been able to get
PrintPreviewDialog to work properly (I have limited time for this
project).

Thank you.
Mar 10 '08 #1
1 2496
On Mar 10, 12:06 pm, Speebs <dougsper...@gmail.comwrote:
Hello,

I have a little form that people can fill out to generate CD labels
from an RTF template. The template basically contains variables that
are replaced by the text typed into the form.

I also have a "Preview" tab which will show a RichTextBoxcontaining
the output of the label generator (ie. the template, with the
variables replaced).

I am able to load the template into a RichTextBox without problems.
This gives me a RichTextBox containing a CD label with words like
%MIDDLE-LEFT% and the other variables.

Then I have the code below, which replaces the text with whatever is
in the user-edited textboxes (eg. txtMiddleLeft.Text):

Expand|Select|Wrap|Line Numbers
  1.         txt_Preview.Rtf = templateRTFText  // this works fine
  2.         tmpVar = Replace(templateRTFText, "%MIDDLE-LEFT%",
  3. txtMiddleLeft.Text, , , CompareMethod.Text)  // this works fine
  4.         txt_Preview.Rtf = "" // this works fine!
  5.         txt_Preview.Rtf = tmpVar // this does not work!
  6.  

This does not work. The variable tmpVar ends up with the correct,
updated data (I checked by copying it to the clipboard and pasting it
into a new RTF file- the variables were replaced). But the
RichTextBox still contains the template text. If I copy
txt_Preview.Rtf to the clipboard, it still contains the template data.

No errors are generated when I run the last line. Can someone please
help me! How should I be accomplishing this?

Note that I am not using PrintPreviewDialog because I need this to
appear inside an existing tab, and I also have not been able to get
PrintPreviewDialog to work properly (I have limited time for this
project).

Thank you.
Have you set a breakpoint on that line and confirmed that it is being
executed? Something else must be setting the value back. Can you
post a short but complete program that demonstrates the problem?

Chris
Mar 11 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Leon | last post by:
Hi. i am currently learning GUI. have learn how to draw button, panel, frames but the problem was, when i run the simple program. all the interface is not drawn properly, or atleast it is draw...
4
by: Joey Powell | last post by:
Hello all. For a long time now I have been struggling with a .net Windows Forms problem. In several of my applications, I use the "Process" class from System.Diagnostics to accomplish various task...
3
by: Sachin | last post by:
If I have an image inside the RichTextBox, can I drag/move it inside the RichTextBox with the help of mouse, just like we can move any control on the form during design time. Please guide -- sachin
0
by: Steve Teeples | last post by:
I have a routine which does a LoadFile. The richtextbox is properly filled. However, the next time I execute an AppendText to it the richtextbox is cleared and the appended text is now the only...
12
by: ThunderMusic | last post by:
hi, I have two classes in C#, one is the base, the other inherits from the base class... both are generics... Here is the definition of the second class : public class...
0
by: wildThought | last post by:
Heres the Deal, My DataSource is not reflecting a recent change to the object its based on. Steps: 1. Changed SQL Server Table 2. Regenerated my DAL(NetTiers) 3. Verified the...
4
by: aaronyoung | last post by:
I have created custom navigation buttons and Record Number indicators on several forms that are used to review and update records based on a query. My On Current event to update the "Record X of...
1
by: kelvin.koogan | last post by:
I am trying to do an operation where I find and highlight all instances of a string in a RichTextBox. E.g. pMatchesFound = Regex::Matches(pRichTextBox->Text, pStr, options); for (int i = 0; i...
2
by: msnews.microsoft.com | last post by:
Hi I have created a webservice with 2 web methods. It was working fine. Now I have added 2 more webmethods to the webservice. The problem is when I try to run the webservice in internet explorer...
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:
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: 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
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...
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
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...

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.