vb.net编制控件 vbnet控件开发( 三 )


RadioButton Size = New System Drawing Size( )
RadioButton TabIndex =
RadioButton Text = 一楼
RadioButton
RadioButton BackColor = System Drawing SystemColors Control
RadioButton Location = New System Drawing Point( )
RadioButton Name = RadioButton
RadioButton Size = New System Drawing Size( )
RadioButton TabIndex =
RadioButton Text = 四楼
分别把它们添加到父控件GroupBox的Controls集合中
GroupBox Controls Add(RadioButton )
GroupBox Controls Add(RadioButton )
GroupBox Controls Add(RadioButton )
GroupBox Controls Add(RadioButton )
GroupBox Controls Add(RadioButton )
GroupBox Controls Add(RadioButton )
GroupBox Controls Add(RadioButton )
GroupBox Controls Add(RadioButton )
GroupBox Controls Add(RadioButton )
GroupBox Controls Add(RadioButton )
End Sub
把上一页的代码复制添加后 把控件初始化过程InitializeControl()过程添加到Form 的New构造函数中 如下图二所示
图二 在New构造函数中添加过程InitializeControl()
现在按F 运行 Form 的窗体控件布局(如下图三所示)是不是和我们手工布局的图一的布局是一样的呢vb.net编制控件?
lishixinzhi/Article/program/ASP/201311/21749
VB.NET 如何做 控件用vs.net创建控件项目vb.net编制控件,其vb.net编制控件他vb.net编制控件的和vb类似...
新建项目-windows 窗体控件库
请教vb.net怎么制作一个可以作为容器的用户控件Public Class 用户控件
InheritsSystem.Windows.Forms.Panel
Public Sub New() '初始化

End Sub
Private Sub 用户控件_KeyDown(sender As Object, e As Forms.KeyEventArgs) Handles Me.KeyDown
' ……
End Sub
'……
End Class
VB.net 如何编写用户控件?Public Class UserControl1
#Region "变量"
Dim Down_Color As Color = Color.Blue
Dim UP_Color As Color = Color.Gray
Dim Mode As Short = 0
Dim flag As Boolean
Dim offset_X As Integer
Dim offset_Y As Integer
Dim Mouse_P As Point
#End Region
#Region "属性"
'按下颜色
Public Property _DownColor As Color
Get
Return Down_Color
End Get
Set(ByVal value As Color)
Down_Color = value
End Set
End Property
'弹起颜色
Public Property _UpColor As Color
Get
Return UP_Color
End Get
Set(ByVal value As Color)
UP_Color = value
End Set
End Property
'滑动模式 0-横 1-竖
Public Property _Mode As Short
Get
Return Mode
End Get
Set(ByVal value As Short)
Mode = value
End Set
End Property
#End Region
Private Sub UserControl1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.BackColor = UP_Color
End Sub
'鼠标按下
Private Sub UserControl1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
Me.BackColor = Down_Color
Mouse_P = e.Location
flag = True
End Sub
'鼠标移动
Private Sub UserControl1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
If flag = False Then Exit Sub
Select Case Mode
Case 0'横向·
offset_X = e.X - Mouse_P.X
If Me.Location.X + offset_X + Me.Width = Me.ParentForm.Width Or Me.Location.X + offset_X = 0 Then
flag = False
Else
Me.Location = New Point(Me.Location.X + offset_X, Me.Location.Y)
End If
Case 1'竖向·
offset_Y = e.Y - Mouse_P.Y
If Me.Location.Y + offset_Y + Me.Height + 30 = Me.ParentForm.Height Or Me.Location.Y + offset_Y = 0 Then
flag = False
Else
Me.Location = New Point(Me.Location.X, Me.Location.Y + offset_Y)

推荐阅读