VB.NET 创建圆角窗体

前端之家收集整理的这篇文章主要介绍了VB.NET 创建圆角窗体前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。


Imports System.Drawing.Drawing2D
Imports System.Drawing

Public Class Form3

Private Sub Form3_Load(ByVal sender As Object,ByVal e As System.EventArgs) Handles Me.Load
Dim path As GraphicsPath = GetRoundedRectPath(Me.ClientRectangle,20)
Me.Region = New Region(path)
End Sub

Private Function GetRoundedRectPath(ByVal Rectangle As Rectangle,ByVal r As Integer) As GraphicsPath
Rectangle.Offset(-1,-1)
Dim RoundRect As New Rectangle(Rectangle.Location,New Size(r - 1,r - 1))
Dim path As New System.Drawing.Drawing2D.GraphicsPath
path.AddArc(RoundRect,180,90) '左上角

RoundRect.X = Rectangle.Right - r '右上角
path.AddArc(RoundRect,270,90)

RoundRect.Y = Rectangle.Bottom - r '右下角
path.AddArc(RoundRect,90)

RoundRect.X = Rectangle.Left '左下角
path.AddArc(RoundRect,90,90)

path.CloseFigure()

Return path
End Function


End Class

日照江诺科技编辑

原文链接:https://www.f2er.com/vb/261962.html

猜你在找的VB相关文章