让TextBox控件显示为一条横线
1、把textbox控件 BorderStyle=FixedSingle 然后在下面加lable显示为横线,这个方法简单,但是麻烦呀。。
2、能不能重写textbox,如何重写(分不够还加。。。)
[解决办法]
Public Class MyTextbox Inherits System.Windows.Forms.TextBox Protected Overrides Sub WndProc(ByRef m As Message) MyBase.WndProc(m) If m.Msg = &HF Then Using g As Graphics = Graphics.FromHwnd(Me.Handle) g.DrawLine(Pens.Blue, 0, Me.ClientRectangle.Height - 1, Me.Width, Me.ClientRectangle.Height - 1) End Using End If End SubEnd Class
[解决办法]
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint For Each Tb As TextBox In Me.Controls If TypeOf (Tb) Is TextBox Then Tb.BorderStyle = BorderStyle.None 去掉边框 e.Graphics.DrawLine(Pens.Black, New Point(Tb.Left, Tb.Top + Tb.Height + 2), New Point(Tb.Left + Tb.Width, Tb.Top + Tb.Height + 2)) End If Next End Sub
[解决办法]