473,625 Members | 2,733 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 RichTextBoxcont aining
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.T ext):

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 PrintPreviewDia log because I need this to
appear inside an existing tab, and I also have not been able to get
PrintPreviewDia log to work properly (I have limited time for this
project).

Thank you.
Mar 10 '08 #1
1 2507
On Mar 10, 12:06 pm, Speebs <dougsper...@gm ail.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 RichTextBoxcont aining
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.T ext):

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 PrintPreviewDia log because I need this to
appear inside an existing tab, and I also have not been able to get
PrintPreviewDia log 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
1757
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 very slowly and not reacting to action fast enough.. There must be a way to fix this, can any1 tell me? here is my simple code, but gui is slow and not responding well when i drag it in side the monitor;
4
4760
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 from within my code (kind of like the old VB shell function). Using this process class appears to be just one example of what causes my Windows forms to look really crazy when running the application. In fact this has become not only a cosmetic...
3
2687
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
1167
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 text visible. Does anyone know why this may be happening? -- Steve
12
1624
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 CNetworkServer<PlayerInfos: CNetworkClient<PlayerInfoswhere PlayerInfos : CPlayerInfos, new() { }
0
1032
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 Regenerated Object has new changes
4
3476
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 Y" is Private Sub Form_Current() Dim frm As Form, LastRec As Long Set frm = Forms!ReviewSearchRecordsForm
1
1608
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 < pMatchesFound->Count; i++) { Match ^m = pMatchesFound; pRichTextBox->SelectionStart = m->Index;
2
1832
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 or access through clients then it doesn't show up the 2 new methods. I will be greatful if anyone can help me out on this issue. Thanking in advance. Regards Fiaz
0
8253
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
8189
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
8692
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
8635
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...
1
8354
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8497
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
6116
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
4192
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1802
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.