We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

windows form print control - brushes -

when print a text document, i want to choose my brushes(brushes.color). but how can i do this? ev.Graphics.DrawString(line, printFont, Brushes.Turquoise, leftMargin, yPos, New StringFormat()) '................... Public Class TextFilePrintDocument Inherits PrintDocument Private printFont As Font Private streamToPrint As StreamReader Public Sub New(ByVal streamToPrint As StreamReader) MyBase.New() Me.streamToPrint = streamToPrint End Sub Protected Overrides Sub OnBeginPrint(ByVal ev As PrintEventArgs) MyBase.OnBeginPrint(ev) printFont = New Font("Arial", 10) End Sub Protected Overrides Sub OnPrintPage(ByVal ev As PrintPageEventArgs) MyBase.OnPrintPage(ev) Dim lpp 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 Dim _colorDialog As New ColorDialog() Dim _brushColor As Brushes lpp = ev.MarginBounds.Height / printFont.GetHeight(ev.Graphics) line = streamToPrint.ReadLine() While ((count < lpp) And Not (line Is Nothing)) yPos = topMargin + (count * printFont.GetHeight(ev.Graphics)) ev.Graphics.DrawString(line, printFont, Brushes.Turquoise, leftMargin, yPos, New StringFormat()) count = count + 1 If (count < lpp) Then line = streamToPrint.ReadLine() End If End While If (line <> Nothing) Then ev.HasMorePages = True Else ev.HasMorePages = False End If End Sub End Class ' TextFilePrintDocument '...................

Loader.
Up arrow icon