标签边框线颜色设置

wangchaocn 2006-02-05 10:19:24
我把标签BoderStyle设置为FixedSingle。
标签的边框线为黑色。
那怎样才能改变边框线颜色呢?如改成蓝色。
...全文
383 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
hamadou 2006-02-06
  • 打赏
  • 举报
回复
创建用户控件,然后把上边的代码复制过去粘贴上去即可。
wangchaocn 2006-02-06
  • 打赏
  • 举报
回复
ding
sky 2006-02-05
  • 打赏
  • 举报
回复
修改该标签的背景色/前景色不行吗?
shichaoreal 2006-02-05
  • 打赏
  • 举报
回复
这个问题查了半天也不知道怎么改,但是可以麻烦点来实现。(相当麻烦)

先作一个窗体form1,把一个label放到窗体上,Borderstyle设为FixedSingle,然后边框是黑色的吧,再把窗体的transparency设为黑色,即黑色透明,在作一个窗体form2,背景色为蓝色,利用form1的窗体移动的事件,取得form1的坐标,把form2放到这个位置上,然后聚焦到form1.

就是让form2老在form1的底下,利用form1上label的透明来显现form2的背景蓝色.

只是form1的黑色以后都会是蓝色,哈

wangchaocn 2006-02-05
  • 打赏
  • 举报
回复
To: hamadou(闵峰--为了理想而奋斗)
您的代码怎么用啊?
shichaoreal 2006-02-05
  • 打赏
  • 举报
回复
还有,没有BorderColor,又不是在写html
shichaoreal 2006-02-05
  • 打赏
  • 举报
回复
hamadou(闵峰--为了理想而奋斗),你在画边框啊,服拉。
wangchaocn 2006-02-05
  • 打赏
  • 举报
回复
感谢各位!

to ghchen()
BoderStyle有FixedSingle值
却找不到BorderColor
我用的是 .net 2003
hamadou 2006-02-05
  • 打赏
  • 举报
回复
Imports System.ComponentModel
Imports System.Drawing

Public Class mytextbox
Inherits System.Windows.Forms.TextBox

Public Sub New()
MyBase.New()

'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()

'在 InitializeComponent() 调用之后添加任何初始化
setstyle(ControlStyles.UserPaint, True)
setstyle(ControlStyles.ResizeRedraw, True)
End Sub
Private _bordercolor As Color = Color.Red

<Description("边框颜色")> _
Public Property BorderColor() As Color
Get
Return _bordercolor
End Get
Set(ByVal Value As Color)
_bordercolor = Value
Me.Invalidate()
End Set
End Property

Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
If Me.BorderStyle = BorderStyle.FixedSingle Then
DrawBackGround(e)
DrawMyString(e)
DrawBorderColor(e)
End If
End Sub

Private Sub DrawBackGround(ByVal e As System.Windows.Forms.PaintEventArgs)
Dim c As Color = Me.BackColor
Dim g As Graphics = e.Graphics
Dim b As New SolidBrush(c)
g.FillRectangle(b, e.ClipRectangle)
End Sub
Private Sub DrawMyString(ByVal e As System.Windows.Forms.PaintEventArgs)
Dim g As Graphics = e.Graphics
Dim w As Single = (Me.Height - g.MeasureString(Me.Text, Me.Font).Height) / 2
g.DrawString(Me.Text, Me.Font, New SolidBrush(Me.ForeColor), 5, w)

End Sub

Private Sub DrawBorderColor(ByVal e As System.Windows.Forms.PaintEventArgs)
Dim g As Graphics = e.Graphics
g.DrawRectangle(New Pen(Me._bordercolor), New Rectangle(0, 0, Me.Width - 1, Me.Height - 1))
End Sub
End Class
ghchen 2006-02-05
  • 打赏
  • 举报
回复
不是有个BorderColor
楼主的Label控件的BoderStyle有FixedSingle值吗?/

16,718

社区成员

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

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