大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
工程里面添加一个类,命名为myGroupBox,代码如下:
儋州网站制作公司哪家好,找创新互联!从网页设计、网站建设、微信开发、APP开发、响应式网站等网站项目制作,到程序开发,运营维护。创新互联成立与2013年到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选创新互联。
Imports System.ComponentModel
Imports System.Drawing.Drawing2D
Public Class myGroupBox
Inherits GroupBox
Public Sub New()
MyBase.BackColor = Color.Transparent
End Sub
Browsable(False) _
Public Overrides Property BackColor() As Color
Get
Return MyBase.BackColor
End Get
Set(value As Color)
MyBase.BackColor = value
End Set
End Property
Private m_backColor As Color = Color.Transparent
Public Property ActualBackColor() As Color
Get
Return Me.m_backColor
End Get
Set(value As Color)
Me.m_backColor = value
End Set
End Property
Protected Overrides Sub OnPaint(e As PaintEventArgs)
Dim tSize As Size = TextRenderer.MeasureText(Me.Text, Me.Font)
Dim borderRect As Rectangle = e.ClipRectangle
borderRect.Y += tSize.Height / 2
borderRect.Height -= tSize.Height / 2
Dim gPath As GraphicsPath = CreatePath(0, borderRect.Y, CSng(Me.Width - 1), borderRect.Height - 1, 5, True, _
True, True, True)
e.Graphics.FillPath(New SolidBrush(ActualBackColor), gPath)
e.Graphics.DrawPath(New Pen(Me.BackColor), gPath)
borderRect.X += 6
borderRect.Y -= 7
e.Graphics.DrawString(Me.Text, Me.Font, New SolidBrush(Me.ForeColor), borderRect)
End Sub
Public Function CreatePath(x As Single, y As Single, width As Single, height As Single, radius As Single, _
RoundTopLeft As Boolean, RoundTopRight As Boolean, RoundBottomRight As Boolean, RoundBottomLeft As Boolean) As GraphicsPath
Dim xw As Single = x + width
Dim yh As Single = y + height
Dim xwr As Single = xw - radius
Dim yhr As Single = yh - radius
Dim xr As Single = x + radius
Dim yr As Single = y + radius
Dim r2 As Single = radius * 2
Dim xwr2 As Single = xw - r2
Dim yhr2 As Single = yh - r2
Dim p As New GraphicsPath()
p.StartFigure()
'Top Left Corner
If RoundTopLeft Then
p.AddArc(x, y, r2, r2, 180, 90)
Else
p.AddLine(x, yr, x, y)
p.AddLine(x, y, xr, y)
End If
'Top Edge
p.AddLine(xr, y, xwr, y)
'Top Right Corner
If RoundTopRight Then
p.AddArc(xwr2, y, r2, r2, 270, 90)
Else
p.AddLine(xwr, y, xw, y)
p.AddLine(xw, y, xw, yr)
End If
'Right Edge
p.AddLine(xw, yr, xw, yhr)
'Bottom Right Corner
If RoundBottomRight Then
p.AddArc(xwr2, yhr2, r2, r2, 0, 90)
Else
p.AddLine(xw, yhr, xw, yh)
p.AddLine(xw, yh, xwr, yh)
End If
'Bottom Edge
p.AddLine(xwr, yh, xr, yh)
'Bottom Left Corner
If RoundBottomLeft Then
p.AddArc(x, yhr2, r2, r2, 90, 90)
Else
p.AddLine(xr, yh, x, yh)
p.AddLine(x, yh, x, yhr)
End If
'Left Edge
p.AddLine(x, yhr, x, yr)
p.CloseFigure()
Return p
End Function
End Class
工具栏会出现一个myGroupBox控件,放入窗体,你会发现边框没了。
可以通过FlatStyle 属性来改变其边框
例如:
Button1.FlatStyle = FlatStyle.Flat
Button1.FlatStyle = FlatStyle.Popup
你把 选项卡 拖到屏幕外面不就行了 只显示选项卡内东西 周围边缘都不要了 每个选项卡内配合labl 或按钮 标识不就行了。
可以利用font 设置。设置方法如下:
TextBox1.Font = New System.Drawing.Font("宋体", 10)
也可以通过字体对话框来实现 如:
Private Sub myButton_Click(sender As Object, e As EventArgs)
Dim myFontDialog As FontDialog
myFontDialog = New FontDialog()
If myFontDialog.ShowDialog() = DialogResult.OK Then
' Set the control's font.
myDateTimePicker.Font = myFontDialog.Font
End If
End Sub
如果要做漂亮的界面的话,我建议你用WPF来做。所有的控件都可以用模板来定义样式。
虚线的话,只需要定义一个矩形,设置一个属性就可以了。前提是,WPF应用程序只能用VS2008或者VS2010来做
要么重写这个控件的 OnPaint 事件,判断 BorderStyle 属性为 FixedSingle 的时候自绘其他颜色。
要么不重写,把 BorderStyle 设为 None,直接在这个控件的 Paint 事件里自绘边框,例如:
Private Sub Label1_Paint(sender As Object, e As PaintEventArgs) Handles Label1.Paint
e.Graphics.DrawRectangle(Pens.Red, New Rectangle(Label1.DisplayRectangle.X, Label1.DisplayRectangle.Y, Label1.DisplayRectangle.Width - 1, Label1.DisplayRectangle.Height - 1))
End Sub
运行效果: