RichTextBox.RTF not updating properly? Please help!!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Speebs

    #1

    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):

    Code:
    txt_Preview.Rtf = templateRTFText  // this works fine
    tmpVar = Replace(templateRTFText, "%MIDDLE-LEFT%",
    txtMiddleLeft.Text, , , CompareMethod.Text)  // this works fine
    txt_Preview.Rtf = "" // this works fine!
    txt_Preview.Rtf = tmpVar // this does not work!
    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.
  • Chris Dunaway

    #2
    Re: RichTextBox.RTF not updating properly? Please help!!

    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):
    >
    Code:
            txt_Preview.Rtf = templateRTFText  // this works fine
            tmpVar = Replace(templateRTFText, "%MIDDLE-LEFT%",
    txtMiddleLeft.Text, , , CompareMethod.Text)  // this works fine
            txt_Preview.Rtf = "" // this works fine!
            txt_Preview.Rtf = tmpVar // this does not work!
    >
    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

    Comment

    Working...