以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 这些代码都是用什么语言编写 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=103463) |
-- 作者:kaituozhe -- 发布时间:2017/7/9 10:03:00 -- 这些代码都是用什么语言编写 这段代码我的目的是美化了一下文本框的显示, Public Sub BeautifyControls(ByVal e As WinForm.Form,ByVal _Values As String)
Dim Values() As String = _Values.Split(",")
For Index As Integer = 0 To Values.Length - 1
Dim BeautifyControl As New BeautifyControl(e.Controls(Values(Index)))
Next
End Sub
Public Class BeautifyControl
Private Control As WinForm.Control
Private Label As WinForm.Label
Public Sub New(ByVal _Control As WinForm.Control)
Dim lbl As WinForm.Label
lbl = _Control.Form.CreateControl("lable1", ControlTypeEnum.Label)
lbl.Name = "lable-" & _Control.Name
lbl.BackColor = Color.Transparent
lbl.TextAlign = ContentAlignment.MiddleLeft
_Control.Parent.AddControl(lbl)
lbl.AutoSize = False
lbl.SetBounds(_Control.Left, _Control.Top, _Control.Width, _Control.Height)
lbl.Anchor = _Control.Anchor
lbl.Dock = _Control.Dock
Me.Control = _Control
Me.Label = lbl
Me.Control.Visible = False
Dim ln As WinForm.Line = _Control.Form.CreateControl("lable1", ControlTypeEnum.Line)
ln.Anchor = _Control.Anchor
_Control.Parent.AddControl(ln)
ln.Left = _Control.Left
ln.Top = _Control.Top + _Control.Height - 16
ln.Width = _Control.Width
AddHandler lbl.BaseControl.Click, AddressOf Label_Click
AddHandler lbl.BaseControl.VisibleChanged, AddressOf Label_VisibleChanged
AddHandler Me.Control.BaseControl.Leave, AddressOf Control_Leave
End Sub
Private Sub Label_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Me.Control.Visible = True
Me.Control.Select()
Me.Control.Form.Controls(Control.Name).BaseControl.SelectionLength = 0
Me.Label.Visible = False
End Sub
Private Sub Label_VisibleChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
If Me.Label.Visible = True Then
If Me.Control.Form.ExistControl(Control.Name) Then
If Me.Control.BindingField = Nothing Then
Me.Label.Text = Me.Control.Form.Controls(Control.Name).Value
Else
Me.Label.BindingField = Me.Control.BindingField
End If
Me.Label.ForeColor = Me.Control.ForeColor
End If
End If
End Sub
\'当文本控件不是活动控件的时候发生
Private Sub Control_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs)
Me.Label.Visible = True
Me.Control.Visible = False
End Sub
End Class |
-- 作者:有点甜 -- 发布时间:2017/7/9 10:09:00 -- vb.net语言,foxtable用的就是vb.net语法。 |