vb.net方框控件,vbs使用窗体控件
如何用VB.NET的知识制作带*的文本框控件
添加一个TextBox控件(比如叫TextBox1)。
创新互联专注于企业全网整合营销推广、网站重做改版、祥云网站定制设计、自适应品牌网站建设、H5页面制作、商城系统网站开发、集团公司官网建设、成都外贸网站建设、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为祥云等各大城市提供网站开发制作服务。
类似于Lable控件的功能,你可以修改TextBox控件的Text属性来达到目的:
不是在设计器里修改,而是在代码中用“TextBox1.Text="你想要显示的字符串";”这样的语句,这样就可以在程序运行时改变显示的内容。
设置或者取消星号,你可以通过代码修改TextBox1的PasswordChar属性,跟上面的是类似的:
在其他的控件的事件中比如Button的Click事件中修改——“TextBox1.PasswordChar="";//不显示***”
“TextBox1.PasswordChar="*(或者任何你想要的字符)";//显示为***”
至于什么时候改就完全随你的意思了。
VB.NET我要用鼠标轨迹画一个矩形框 然后选中控件。就像星际和魔兽争霸里对部队单位的选中一样~等大神回答
这个类继承自Panel,把它加到你的项目里面,先运行一下,然后从工具箱里把它拖到窗体上,然后再向里面添加其它控件就可以了,支持Shift加选,Alt减选
Imports System.Linq
Imports System.Collections
Public Class MyPanel
Inherits Panel
' 选择模式,相交还是包含
Enum SelectMode
Intersects
Contains
End Enum
Dim down As New Point(-1, -1)
Dim rect As Rectangle
Dim selected As New List(Of Control)
Dim editting As IEnumerable(Of Control)
Dim mode As SelectMode = SelectMode.Contains
Dim shift, alt As Boolean
Public Sub New()
Me.DoubleBuffered = True
End Sub
Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
MyBase.OnMouseDown(e)
down = e.Location
editting = selected.ToArray().ToList()
OnMouseMove(e)
End Sub
Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
MyBase.OnMouseMove(e)
If e.Button = Windows.Forms.MouseButtons.Left Then
Dim loc As New Point(Math.Min(down.X, e.X), Math.Min(down.Y, e.Y))
Dim size As New Size(Math.Abs(down.X - e.X), Math.Abs(down.Y - e.Y))
rect = New Rectangle(loc, size)
Dim cs As New List(Of Control)
For Each c In Controls
cs.Add(c)
Next
Dim a = cs.Where(Function(n As Control) (mode = SelectMode.Contains And rect.Contains(n.Bounds)) Or (mode = SelectMode.Intersects And rect.IntersectsWith(n.Bounds)))
If shift Then editting = a.Union(selected) Else If alt Then editting = selected.Except(a) Else editting = a
Invalidate()
End If
End Sub
Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
MyBase.OnMouseUp(e)
down = New Point(-1, -1)
selected = editting.ToList()
editting = Nothing
Invalidate()
End Sub
Protected Overrides Function ProcessKeyPreview(ByRef m As Message) As Boolean
Dim KeyCode As Keys = CInt(m.WParam) And CInt(Keys.KeyCode)
Dim d As Boolean
If m.Msg = H100 Or m.Msg = H104 Then d = True Else If m.Msg = H101 Or m.Msg = H105 Then d = False Else Return MyBase.ProcessKeyPreview(m)
If KeyCode = Keys.ShiftKey Then
shift = d
ElseIf KeyCode = Keys.Menu Then
alt = d
End If
Return MyBase.ProcessKeyPreview(m)
End Function
Protected Overrides Sub OnPaint(e As PaintEventArgs)
MyBase.OnPaint(e)
For Each c As Control In IIf(editting Is Nothing, selected, editting)
e.Graphics.DrawRectangle(New Pen(Color.Gray) With {.DashStyle = Drawing2D.DashStyle.DashDot}, c.Left - 1, c.Top - 1, c.Width + 1, c.Height + 1)
Next
If (down.X 0) Then e.Graphics.DrawRectangle(New Pen(Color.Gray) With {.DashStyle = Drawing2D.DashStyle.DashDot}, rect)
End Sub
End Class
VB.NET中的文本框控件txtScore,txtAvg,txtMax,txtMin,txtNum,txtBNum,txtBRate,txtCNum...在哪里?
文本框控件就是TextBox,只有一个,至于你说的txtScore,txtAvg,txtMax,txtMin。。。。这些都是实例,你把文本框控件拖到窗体,然后起这些名字就可以了。
vb.net combobox 控件
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ComboBox1.Items.Add("米")
ComboBox1.Items.Add("分米")
ComboBox1.Items.Add("厘米")
ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Select Case ComboBox1.SelectedIndex
Case 0
TextBox1.Text = "1"
Case 1
TextBox1.Text = "10"
Case 2
TextBox1.Text = "100"
Case Else
TextBox1.Text = ""
End Select
End Sub
End Class
本文名称:vb.net方框控件,vbs使用窗体控件
地址分享:http://myzitong.com/article/hecods.html