如何在表格上剪一个洞? [英] How do I cut a hole on a Form?
本文介绍了如何在表格上剪一个洞?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在VB.NET 2010中创建/剪切圆孔?
How do I create/cut a circular hole in VB.NET 2010?
推荐答案
您尚未指定是使用Windows窗体还是WPF,而是因为你谈到一个表单,我假设你使用Windows Forms。
首先,将其添加到代码文件的顶部:
You haven't specified whether you use Windows Forms or WPF, but because you talk about a "Form", I assume you use Windows Forms.
First, add this to the top of your code file:
Imports System.Drawing.Drawing2D
为了打个洞,请执行以下操作:
And to make a hole, do this:
Dim hole As New GraphicsPath()
Dim x As Integer = 0
Dim y As Integer = 0
Dim width As Integer = 100
Dim height As Integer = 100
hole.AddEllipse(x, y, width, height)
Dim formRegion As New Region(New Rectangle(Point.Empty, Me.Size))
formRegion.Exclude(hole)
Me.Region = formRegion
请注意,这有副作用:将值设置为 Me.Region
后,样式为表格边框更改。
Note that this has a side effect: after setting a value to Me.Region
, the style of the form border changes.
这篇关于如何在表格上剪一个洞?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文