-
Mar 6th, 2018, 05:38 PM
#1
Thread Starter
Lively Member
[RESOLVED] How to set draw rectangle backstyle to opaque
The following code successfully creates a rectangle to be printed. The problem is that I need that rectangle to be opaque, but the created on is not. I have been trying to set the rectangle backstyle to opaque, with no success at all.
I need some help to get it opaque.
Thank you so much
Nelson Calabria
HTML Code:
Dim AmortizableLblRect As New Rectangle
Dim myPen As Drawing.Pen
Dim drawBrush As New SolidBrush(Color.White)
CurrentX = CantidadLblRect.Right + ancho + 3
CurrentY = ConceptoTxtRect.Bottom + 5
AmortizableLblRect = New Rectangle(CurrentX, CurrentY, AmortizableLblRect.Width, AmortizableLblRect.Height)
myPen = New Drawing.Pen(Color.Black, 1)
e.Graphics.FillRectangle(drawBrush, AmortizableLblRect)
e.Graphics.DrawRectangle(myPen, AmortizableLblRect)
-
Mar 6th, 2018, 05:59 PM
#2
Re: How to set draw rectangle backstyle to opaque
remove...
Code:
e.Graphics.FillRectangle(drawBrush, AmortizableLblRect)
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Mar 6th, 2018, 06:06 PM
#3
Thread Starter
Lively Member
Re: How to set draw rectangle backstyle to opaque
Hello .paul.:
Appreciate your response. I removed the sentence you said, but it did not work.
Thanks any way.
Nelson Calabria
-
Mar 6th, 2018, 06:31 PM
#4
Thread Starter
Lively Member
Re: How to set draw rectangle backstyle to opaque
Hello .paul.:
Appreciate your response. I removed the sentence you said, but it did not work.
Thanks any way.
Nelson Calabria
-
Mar 6th, 2018, 06:52 PM
#5
Re: How to set draw rectangle backstyle to opaque
Can you post a screenshot of how it appears and explain what you want to be different?
If you draw a rectangle, and don't fill the rectangle with a solid color, it'll show a border with the background it's drawn on showing through the rectangle...
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Mar 6th, 2018, 06:58 PM
#6
Re: How to set draw rectangle backstyle to opaque
If you want a semi-transparent background, use a color with an alpha channel less than 255.
Dim c as color = color.fromargb(50, color.white.r, color.white.g, color.white.b)
Creates a semi transparent white color
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Mar 6th, 2018, 07:05 PM
#7
Thread Starter
Lively Member
Re: How to set draw rectangle backstyle to opaque
Hi .paul.,
The draw rectangle is to be printed, as I said when I posted the thread. What I am trying to get is a printout of something like a group box, i.e. a rectangle and a label on its top side.
Nelson
-
Mar 6th, 2018, 07:37 PM
#8
Re: How to set draw rectangle backstyle to opaque
here's an example... You'll have to change the coordinates and size and text.
Code:
Imports System.Drawing.Printing
Public Class Form1
Private WithEvents pd As New PrintDocument
Private ppd As New PrintPreviewDialog
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ppd = New PrintPreviewDialog
ppd.Document = pd
ppd.WindowState = FormWindowState.Maximized
ppd.ShowDialog()
End Sub
Private Sub pd_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles pd.PrintPage
Dim leftOfGroupbox As Integer = 50
Dim topOfGroupbox As Integer = 50
Dim widthOfGroupbox As Integer = 200
Dim heightOfGroupbox As Integer = 150
Dim groupBoxText As String = "Groupbox Text"
''this section can be repositioned and resized by changing the 5 variables above
''******************************************************************************
e.Graphics.FillRectangle(New SolidBrush(SystemColors.Control), New Rectangle(leftOfGroupbox, topOfGroupbox, widthOfGroupbox, heightOfGroupbox))
ControlPaint.DrawBorder(e.Graphics, New Rectangle(leftOfGroupbox + 10, topOfGroupbox + 10, widthOfGroupbox - 20, heightOfGroupbox - 20), Color.DarkGray, ButtonBorderStyle.Solid)
Dim sizef As SizeF = e.Graphics.MeasureString(groupBoxText, Me.Font)
Dim r As New Rectangle(leftOfGroupbox + 25, topOfGroupbox, CInt(sizef.Width + 5), CInt(sizef.Height + 10))
e.Graphics.FillRectangle(New SolidBrush(SystemColors.Control), r)
Dim sf As New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center}
e.Graphics.DrawString(groupBoxText, Me.Font, Brushes.Black, r, sf)
''******************************************************************************
ControlPaint.DrawCheckBox(e.Graphics, New Rectangle(70, 80, 16, 16), ButtonState.Checked)
e.Graphics.DrawString("Is this ok?", Me.Font, Brushes.Black, 100, 80)
End Sub
End Class
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Mar 6th, 2018, 08:06 PM
#9
Thread Starter
Lively Member
Re: How to set draw rectangle backstyle to opaque
Hi .paul.
That was great.
Thank you so much.
Nelson
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|