请问如何设置label边框的颜色

yunfei0103 2006-10-16 02:03:13
如题,请高手指点
...全文
1732 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
yunfei0103 2006-10-16
  • 打赏
  • 举报
回复
问题解决了,十分感谢
malingxian 2006-10-16
  • 打赏
  • 举报
回复
'给你个演示,嘻嘻。

Public Class LabelTest
Inherits System.Windows.Forms.Label

#Region " 组件设计器生成的代码 "

Public Sub New(Container As System.ComponentModel.IContainer)
MyClass.New()

'Windows.Forms 类撰写设计器支持所必需的
Container.Add(me)
End Sub

Public Sub New()
MyBase.New()

'该调用是组件设计器所必需的。
InitializeComponent()

'在 InitializeComponent() 调用之后添加任何初始化

End Sub

'组件重写 dispose 以清理组件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'组件设计器所必需的
Private components As System.ComponentModel.IContainer

'注意: 以下过程是组件设计器所必需的
'可以使用组件设计器修改此过程。
'不要使用代码编辑器修改它。
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
components = New System.ComponentModel.Container()
End Sub

#End Region

Private p_BorderColor As Color = Color.Gray '默认为灰色
Private Property BorderColor() As Color
Get
Return p_BorderColor
End Get
Set(ByVal Value As Color)
p_BorderColor = Value
End Set
End Property

Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
MyBase.OnPaint(e)
If MyBase.BorderStyle = BorderStyle.None Then '如果是无边框则绘制,否则不予理睬
Dim drp As New System.Drawing.Pen(p_BorderColor)
Dim crect As Rectangle = e.ClipRectangle
crect.Inflate(-1, -1)
e.Graphics.DrawRectangle(drp, crect)
drp.Dispose()
End If
End Sub
End Class
stone_soup 2006-10-16
  • 打赏
  • 举报
回复
Private Sub Label1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Label1.Paint
e.Graphics.DrawRectangle(New Pen(Color.Blue), e.ClipRectangle.X, e.ClipRectangle.Y, e.ClipRectangle.Width - 1, e.ClipRectangle.Height - 1)
End Sub
yunfei0103 2006-10-16
  • 打赏
  • 举报
回复
如何重绘,请说的仔细点可以么?谢谢了先
yunfei0103 2006-10-16
  • 打赏
  • 举报
回复
对不起,我忘说了,是windows应用程序,不是web程序
malingxian 2006-10-16
  • 打赏
  • 举报
回复
WinForm?ASP.NET?
前者的话需要自定义控件进行重绘。
xiaoqhuang 2006-10-16
  • 打赏
  • 举报
回复
BorderWidth="1px" BorderColor="Red"

16,721

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧