Mi scuso con i moderatori per aver riproposto questo topic ma purtroppo sono nei guai seri.
non riesco a completare questo progetto e purtroppo lo dovevo consegnare oggi.
Ho bisogno di qualcuno che mi da una mano.
Vi prego di cuore di aiutarmi a scrivere il codice con i passi di Bryanjar.
Ripropongo il mio problema.
Quando stampo e il contenuto della txtBox e maggiore della lunghezza del foglio la stampante non va a capo e quindi non mi stampa tutta la stringa del txBox.
come devo fare?
Bryanjar mi ha suggerito queste soluzioni solo che non so costruirle.
qualcuno sa farlo
vi ringrazio


Brianjar:
Ti devi costruire una funzione di parsing delle stringe contenute
nel textBox.
Una volta che stabilisci quanti caratteri nR per riga devi stampare
fai così :

1) Rimpiazza (con il metodo Replace) tutti i CRLF eventualmente
presenti nella stringa textbox con uno spazio (copiala in una nuova stringa).
2) Estrai (con Substring) la prima riga di nR caratteri
3) Se l'ultimo carattere non è spazio ripeti il passo 2 con nR
decrementato di uno (usa una variabile che aumenti ad ogni tentativo.)
4) Se l'ultimo carattere è uno spazio allora aggiungi la prima riga
alla stringa da stampare. Decrementa la stringa della textbox.
5) ripeti il tutto fino a quando la stringa della text non è
vuota ed hai aggiunto tutti i pezzi alla stringa da stampare.
La funzione dovrebbe essere invocata in questo punto :


vi ricordo che il codice è


code:--------------------------------------------------------------------------------
Public Class Form2

Imports System.IO
Imports System.Drawing.Printing

Public Class Form3

Private printFont As Font
Private streamToPrint As StreamReader
Private Shared filePath As String

' Print the file.
Private Sub Printing()
Try
streamToPrint = New StreamReader("C:\App.txt")
Try
printFont = New Font("Arial", 10)
Dim pd As New PrintDocument()
AddHandler pd.PrintPage, AddressOf pd_PrintPage
' Print the document.
pd.Print()
Finally
streamToPrint.Close()
End Try
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub

' The PrintPage event is raised for each page _
to be printed.
Private Sub pd_PrintPage(ByVal sender As Object, _
ByVal ev As PrintPageEventArgs)

Dim linesPerPage As Single = 0
Dim yPos As Single = 0
Dim count As Integer = 0
Dim leftMargin As Single = ev.MarginBounds.Left
Dim topMargin As Single = ev.MarginBounds.Top
Dim line As String = Nothing

' Calculate the number of lines per page.
linesPerPage = _
ev.MarginBounds.Height / printFont.GetHeight(ev.Graphics)

' Iterate over the file, printing each line.
While count < linesPerPage
line = streamToPrint.ReadLine()
If line Is Nothing Then
Exit While
End If
yPos = _
topMargin + count * printFont.GetHeight(ev.Graphics)
ev.Graphics.DrawString(line, printFont, Brushes.Black, _
leftMargin, yPos, New StringFormat())
count += 1
End While

' If more lines exist, print another page.
If Not (line Is Nothing) Then
ev.HasMorePages = True
Else
ev.HasMorePages = False
End If
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim fFile As StreamWriter
Dim strDoc As String = ""

strDoc = strDoc + TextBox21.Text + vbCrLf + vbCrLf
strDoc = strDoc + TextBox24.Text + vbCrLf + vbCrLf
strDoc = strDoc + TextBox22.Text + vbCrLf + vbCrLf
strDoc = strDoc + TextBox23.Text + vbCrLf + vbCrLf + vbCrLf


strDoc = strDoc + TextBox1.Text
strDoc = strDoc + " " + TextBox11.Text + vbCrLf + vbCrLf

strDoc = strDoc + TextBox2.Text
strDoc = strDoc + " " + TextBox12.Text + vbCrLf + vbCrLf

strDoc = strDoc + TextBox3.Text
strDoc = strDoc + " " + TextBox13.Text + vbCrLf + vbCrLf

strDoc = strDoc + TextBox4.Text
strDoc = strDoc + " " + TextBox14.Text + vbCrLf + vbCrLf

strDoc = strDoc + TextBox5.Text
strDoc = strDoc + TextBox15.Text + vbCrLf + vbCrLf

strDoc = strDoc + TextBox6.Text
strDoc = strDoc + " " + TextBox16.Text + vbCrLf + vbCrLf

strDoc = strDoc + TextBox7.Text
strDoc = strDoc + " " + TextBox17.Text + vbCrLf + vbCrLf

strDoc = strDoc + TextBox8.Text
strDoc = strDoc + " " + TextBox18.Text + vbCrLf + vbCrLf

strDoc = strDoc + TextBox9.Text
strDoc = strDoc + " " + TextBox19.Text + vbCrLf + vbCrLf

strDoc = strDoc + TextBox10.Text
strDoc = strDoc + " " + TextBox20.Text + vbCrLf + vbCrLf



fFile = File.CreateText("C:\App.txt")
fFile.WriteLine(strDoc)
fFile.Close()

Printing()
File.Delete("C:\App.txt")
End Sub
--------------------------------------------------------------------------------

raga mi date qusto aiuto per favore
io non sono tanto bravo sto imparando.
scusatemi
ringrazio tutti quelli che mi stanno aiutando in particolare ladyblu e brianjar