locked
Printing Text with multiple Lines

    Question

  • Hello,

    i want to print a list and in that is text with multiple lines.

    In the PrintPreview and in the Printout i get only one line.
    How is the best way to do this?

    Thank you,
    Markus

     Private Function Print_Remarks_Control_Get(ByVal pstrText As String) As TextBox
        Dim TextBox_Out As New TextBox
    
        With TextBox_Out
          .Text = pstrText
          .HorizontalAlignment = Xaml.HorizontalAlignment.Left
          .VerticalAlignment = Xaml.VerticalAlignment.Top
          .FontSize = 16
          .Margin = New Thickness(15)
          .AcceptsReturn = True
          .MinWidth = 800
          .MinHeight = 600
        End With
    
        Return TextBox_Out
      End Function
    
      Sub PrintPageList_Prepare()
        Dim i As Integer
        Dim objVM As clsTextVM
        Dim lstText_List As ObservableCollection(Of clsText)
    
        Dim ctrPrint_StackPanel As StackPanel
        Dim ctrPrint_Title As TextBox
        Dim ctrPrint_Description As TextBox
        Dim ctrPrint_Remarks As TextBox
    
        Dim objText As clsText
    
        mPrintPageList.Clear()
        objVM = DirectCast(Me.DataContext, clsTextVM)
        lstText_List = objVM.CustomClass_List
    
        ctrPrint_StackPanel = Print_StackPanel_Get()
    
        For i = 0 To lstText_List.Count - 1
          objText = lstText_List.Item(i)
    
          If objText.Name.Length > 0 Then
            ctrPrint_Title = Print_Title_Control_Get(objText.Name)
            ctrPrint_StackPanel.Children.Add(ctrPrint_Title)
          End If
    
          If objText.Description.Length > 0 Then
            ctrPrint_Description = Print_Description_Control_Get(objText.Description)
            ctrPrint_StackPanel.Children.Add(ctrPrint_Description)
          End If
    
          If objText.Remarks.Length > 0 Then
            ctrPrint_Remarks = Print_Description_Control_Get(objText.Remarks)
            ctrPrint_StackPanel.Children.Add(ctrPrint_Remarks)
          End If
    
        Next
    
        mPrintPageList.Add(ctrPrint_StackPanel)
    
      End Sub
    
      Private Sub OnGetPreviewPage(sender As Object, e As GetPreviewPageEventArgs)
        ' Das ist die MessageBox
        ' Windows.UI.Popups.MessageDialog()
    
        PrintPageList_Prepare()
    
        mPrintDok.SetPreviewPage(e.PageNumber, Me.mPrintPageList(e.PageNumber - 1))
      End Sub
    

    Tuesday, March 17, 2015 3:02 PM

Answers

  • It works with a RichEditBox. I had to calculate the Height with Fontsize and Number of Line of Text and use Textwrapping.

    • Marked as answer by Markus222 Tuesday, March 17, 2015 5:19 PM
    Tuesday, March 17, 2015 5:19 PM

All replies

  • It works with a RichEditBox. I had to calculate the Height with Fontsize and Number of Line of Text and use Textwrapping.

    • Marked as answer by Markus222 Tuesday, March 17, 2015 5:19 PM
    Tuesday, March 17, 2015 5:19 PM
  • Yes, not only RichEditBox but also RichTextBlock can also do this. Besides TextBox also have TextWrapping functionality.

    -James


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, March 18, 2015 1:28 AM
    Moderator