What is wrong with this code
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
6 posts
Page 1 of 1
i have this simple graphics path but i cant fill it with a color
Code: Select all
and i use it with this code
Private Function DrawLeftTriangle(ByVal r As Rectangle) As GraphicsPath
Dim path As New GraphicsPath
path.AddLine(r.X, r.Y + Convert.ToInt32(r.Height / 2), r.X + r.Width, r.Y)
path.AddLine(r.X, r.Y + Convert.ToInt32(r.Height / 2), r.X + r.Width, r.Y + r.Height)
path.AddLine(r.X + r.Width, r.Y, r.X + r.Width, r.Y + r.Height)
path.CloseFigure()
Return path
End Function
Code: Select all
this only draws the outline border but it doesn fill the interior Why? e.Graphics.FillPath(Brushes.Red, DrawLeftTriangle(New Rectangle(50, 50, 10, 10)))
e.Graphics.DrawPath(Pens.Black, DrawLeftTriangle(New Rectangle(50, 50, 10, 10)))
You can find me on Facebook or on Skype mihai_92b
You might have to Draw it first and then Fill it? Dont know, I suck with graphics.
Practice makes perfect!
VIP since: 6-10-2011
VIP since: 6-10-2011
You're only changing the colours of the lines of the Rectangle.
To fill it you can use:
To fill it you can use:
Code: Select all
Dim redbrush As New SolidBrush(Color.Red)
e.Graphics.FillRectangle(redbrush, x, y, width, height)
My name is Tom | Visit my blog where I post new content every day! Tom's Daily Blog | MineCraft is awesome!
smashapps wrote:You're only changing the colours of the lines of the Rectangle.i need to fill a graphics path not a rectangle
To fill it you can use:
Code: Select allDim redbrush As New SolidBrush(Color.Red) e.Graphics.FillRectangle(redbrush, x, y, width, height)
You can find me on Facebook or on Skype mihai_92b
Code: Select all
Private Function DrawLeftTriangle (ByVal r As Rectangle) As GraphicsPath
Dim path As New GraphicsPath
path. AddLine(r.Right, r.Top, r.Left , r.height/2)
path.addline( r.Left , r.height/2, r.right,r.bottom)
path. AddLine(r.right,r.bottom, r.right,r.top)
path. CloseFigure()
Return path
End Function
M1z23R wrote:Doesn't WorkCode: Select allPrivate Function DrawLeftTriangle (ByVal r As Rectangle) As GraphicsPath Dim path As New GraphicsPath path. AddLine(r.Right, r.Top, r.Left , r.height/2) path.addline( r.Left , r.height/2, r.right,r.bottom) path. AddLine(r.right,r.bottom, r.right,r.top) path. CloseFigure() Return path End Function
You can find me on Facebook or on Skype mihai_92b
6 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023