Visual basic 2005 Express Edition:
I have a large subroutine that handles printed output. I want to call the same subroutine, but, with different colors.
How can I substitute RadioButtonBrush for Brushes.Black, for example, in the code below, so that I can change the color of RadioButtonBrush before calling the subroutine
xPos = Center - 1
.DrawString(RadioButtonTxt(i), _
mFont, Brushes.Black, xPos, yPos)
yPos += lineHeight

How do I set a variable for Brushes?
Capistrc
' Under Public Class Form1 say
Private mycolor As Brush
' have some event code set the color you want
mycolor = Brushes.Blue
' in your drawstring statement, replace brushes.black with MYCOLOR
e.Graphics.DrawString(stringForPage, PrintFont, _
mycolor, rectDraw, strFormat)
This seems to work in a test I just did. I am a VB beginner
batman900
That worked great!
My problem was, I wasn't Dimming it in the Public area.
Thanks a million!
mcmcom
You are welcome.
Your question also got me looking at how to print in the same color as
the foreground text font I was using. I came up with the following. (Lightly tested but works so far. You might want to add some good 'ol TRY/CATCH for safety.)
(It seems that brushes and solidbrush work the same for what I am doing, however, solidbrush is easier to 'tag a font color' to.)
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage Dim Brush = New SolidBrush(RichTextBox1.ForeColor)...........
'Print string on current page
e.Graphics.DrawString(stringForPage, PrintFont, _
Brush, rectDraw, strFormat) ..............
So far it seems to work. Remember, I am a beginner to Visual Basic.
(Solution derived from post at http://www.dotnet247.com/247reference/msgs/37/189841.aspx)