首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VB Dotnet >

怎么改变GroupBox的边框线颜色

2012-01-22 
如何改变GroupBox的边框线颜色?如何改变GroupBox的边框线颜色?是否需要重写GroupBox?具体怎样实现?[解决办

如何改变GroupBox的边框线颜色?
如何改变GroupBox的边框线颜色?是否需要重写GroupBox?具体怎样实现?

[解决办法]
自己写一个吧

VB.NET code
Imports System.ComponentModelPublic Class GroupBoxControl    Inherits Panel    Private lbl As Label    Private mBorderColor As Color = Color.Blue    <Browsable(True)> _        Public Overrides Property Text() As String        Get            Return lbl.Text        End Get        Set(ByVal value As String)            lbl.Text = value            Me.Invalidate()        End Set    End Property    Public Property BorderColor() As Color        Get            Return mBorderColor        End Get        Set(ByVal value As Color)            mBorderColor = value            Me.Invalidate()        End Set    End Property    Private Sub GroupBoxControl_ControlAdded(ByVal sender As Object, ByVal e As System.Windows.Forms.ControlEventArgs) Handles Me.ControlAdded        If e.Control.Left < 5 Then e.Control.Left = 5        If e.Control.Top < 15 Then e.Control.Top = 15        If e.Control.Right > Me.Width - 10 Then e.Control.Left = Me.Width - 10 - e.Control.Width        If e.Control.Bottom > Me.Height - 10 Then e.Control.Top = Me.Height - 10 - e.Control.Height    End Sub    Private Sub GroupBoxControl_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint        e.Graphics.DrawRectangle(New Pen(mBorderColor), New Rectangle(2, 8, Me.Width - 5, Me.Height - 12))    End Sub    Public Sub New()        lbl = New Label        lbl.AutoSize = True        lbl.Text = "GroupBox"        Me.Controls.Add(lbl)    End Sub    Private Sub GroupBoxControl_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize        lbl.Location = New Point(10, 1)    End SubEnd Class
[解决办法]
还不如把边框设为不显示
然后自己画4条线上去

热点排行