我们专注攀枝花网站设计 攀枝花网站制作 攀枝花网站建设
成都网站建设公司服务热线:400-028-6601

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

vb.net编写控件 vb控件代码

vb.net 如何编写一个程序,能自由创建控件(比如说创建textbox),就像设计时一样

Dim Mouse_X, Mouse_Y As Integer, Mouse_ZF As New PictureBox

在肇州等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供成都网站建设、网站建设 网站设计制作定制网站开发,公司网站建设,企业网站建设,品牌网站制作,营销型网站建设,外贸网站建设,肇州网站建设费用合理。

Private Sub Form1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown

If e.Button = Windows.Forms.MouseButtons.Left Then

Mouse_X = e.X

Mouse_Y = e.Y

Mouse_ZF.Location = New Point(e.X - 1, e.Y - 1)

Mouse_ZF.Size = New Size(0, 0)

Mouse_ZF.BorderStyle = BorderStyle.FixedSingle

Mouse_ZF.BackColor = Color.Silver

Mouse_ZF.Visible = True

Mouse_ZF.Name = "ZF"

Me.Controls.Add(Mouse_ZF)

Else

Mouse_X = 0

Mouse_Y = 0

End If

End Sub

Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove

If e.Button = Windows.Forms.MouseButtons.Left Then

Mouse_ZF.Size = New Size(e.X - Mouse_X, e.Y - Mouse_Y)

End If

End Sub

Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp

If e.Button = Windows.Forms.MouseButtons.Left Then

Mouse_ZF.Visible = False

Dim TB As New TextBox

TB.Location = New Point(Mouse_X + 1, Mouse_Y + 1)

TB.Multiline = True

TB.Size = Mouse_ZF.Size

Me.Controls.Remove(Me.Controls.Item("ZF"))

Me.Controls.Add(TB)

End If

End Sub

VB.NET 如何做 控件

用vs.net创建控件项目,其他的和vb类似...

新建项目-windows 窗体控件库

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)

End If

End Select

End Sub

'鼠标弹起

Private Sub UserControl1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp

Me.BackColor = UP_Color

flag = False

End Sub

End Class


当前名称:vb.net编写控件 vb控件代码
转载源于:http://shouzuofang.com/article/dodsjds.html

其他资讯