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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

windows form print control - brushes -

Thread ID:




1153 Sep 27,2002 07:40 AM UTC WinForms 0
Tags: FAQ
Asked On September 27, 2002 07:40 AM UTC

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 '...................


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon