4

So I have a C1TrueDBGrid on my form (which is a ComponentOne control), and I give the user the option to print the contents of the grid.

When printed, I include a header with some text. This is my code for printing:

    Dim dlgPrint As New PrintDialog
    dlgPrint.ShowDialog()

    dgvList.PrintInfo.PrintEmptyGrid = False
    dgvList.PrintInfo.PageHeader = txtDirectory.Text & Environment.NewLine & "Search Term: " & txtSearch.Text & Environment.NewLine
    dgvList.PrintInfo.PageSettings.Landscape = True
    dgvList.PrintInfo.WrapText = C1.Win.C1TrueDBGrid.PrintInfo.WrapTextEnum.Wrap
    dgvList.PrintInfo.RepeatColumnHeaders = True

    dgvList.PrintInfo.Print(dlgPrint.PrinterSettings)

    dlgPrint.Dispose()

txtDirectory.Text as I'm sure you can imagine contains the path for a directory, which includes back-slashes \ . What actually got printed turned the instances of \S into 1.

For example: txtDirectory.Text = \\Server02\Users\Me\J\Star

page that got printed = \1erver02\Users\Me\J1tar

Is "\S" a printer command for "1" or something? Is there a list somewhere of what all such commands are, if that's the case? Either way, how do I get it to print the actual text?

Thank you!

Andy
  • 616
  • 11
  • 32

2 Answers2

1

You are setting that text to a PageHeader, and according to ComponentOne, \S is a special character that returns the total number of sub-pages, or "1" in your example. You will need to double-escape any of the characters in the list on that page.

DonBoitnott
  • 10,787
  • 6
  • 49
  • 68
  • Thank you for finding that! Noob question, though - I'll need to "double-escape" those kinds of characters...how, exactly? – Andy May 18 '15 at 18:31
  • It would appear that C1 has not employed an obvious way to escape the characters. Monitor [this forum post](http://our.componentone.com/groups/topic/pageheader-containing-special-characters-in-string/) for a possible solution. – DonBoitnott May 18 '15 at 20:19
0

Updates have been posted to this ComponentOne forum thread.

So what I did was to simply assign the string I want to print to a variable printText and then replace those special characters accordingly:

    printText.Replace("\t", "\\t")
    printText.Replace("\p", "\\p")
    printText.Replace("\P", "\\P")
    printText.Replace("\g", "\\g")
    printText.Replace("\G", "\\G")
    printText.Replace("\s", "\\s")
    printText.Replace("\S", "\\S")

Just note that the "\\t" is not yet working like the others...they are looking into it.

Thanks @DonBoitnott for the original link!

Andy
  • 616
  • 11
  • 32