1

I'm trying to create a circle but the problem is that the box appears in the background.

Is there any way to resolve this problem?

enter image description here

I tried:

Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
   Dim G As Graphics = e.Graphics
   G.SmoothingMode = SmoothingMode.AntiAlias
   G.FillEllipse(Pens.Red, 2, 2, Width - 4, Height - 4)
End Sub
Idle_Mind
  • 38,363
  • 3
  • 29
  • 40
ZAK_99
  • 11
  • 2
  • Is that circle being drawn in a UserControl maybe? What are we looking at here? – Idle_Mind Jan 17 '23 at 13:47
  • yes exactly, i want to draw just the circle and hide rectangle in background. – ZAK_99 Jan 17 '23 at 17:14
  • The rectangle is the literal SHAPE of the UserControl. To "remove" the rectangle", you'd have to make a [Region](https://learn.microsoft.com/en-us/dotnet/api/system.drawing.region?view=windowsdesktop-7.0) containing just the circle and assign it to the Region property of your UserControl. First create a [GraphicsPath](https://learn.microsoft.com/en-us/dotnet/api/system.drawing.drawing2d.graphicspath?view=dotnet-plat-ext-6.0) and draw the circle to that. Now pass that GraphicsPath to the Region's Constructor when you create it. [Here's an example](https://stackoverflow.com/a/27046493/2330053). – Idle_Mind Jan 17 '23 at 19:41

0 Answers0