vb.net控件编程 vbnet chart控件( 三 )


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 的窗体控件布局(如下图三所示)是不是和我们手工布局的图一的布局是一样的呢?
lishixinzhi/Article/program/ASP/201311/21749
如何轻松调整VB.NET控件 Anchor属性可以被设定为Top Bottom Left和Right的任何组合 默认设置是Top Left 这可以保持控件的top left角与视窗边框具有相同的相对位置 设置Anchor属性为Top and Bottom可以垂直地调整控件 保证从视窗底部到控件底部距离相同
Me TextBox Anchor = (System Windows Forms AnchorStyles Top Or System Windows Forms AnchorStyles Left)
Dock属性
这个属性可以被设置为Top Bottom Left Right或Fill 将其设置为Top Bottom Left或Right可以使控件紧挨指定的视窗边缘 或者紧挨已放置到相应视窗边缘的其他控件 设置Dock属性为Fill可以使控件调整为充满视窗的整个客户区
Me Panel Dock = System Windows Forms DockStyle Bottom
你还可以使用DockPadding对象来设置填充视窗边框和已放置好的控件间的区域 它有对应每个视窗边框的属性 如果想要边框对每个边都一致也可以通过设置All属性实现
Me DockPadding All =lishixinzhi/Article/program/net/201311/14503
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'横向·

推荐阅读