重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
用vs.net创建控件项目,其他的和vb类似...
网站建设哪家好,找创新互联!专注于网页设计、网站建设、微信开发、小程序制作、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了宾县免费建站欢迎大家使用!
新建项目-windows 窗体控件库
先生成dataset,然后用datarow装载dataset的需要编辑的记录,再把datarow的值赋给textbox的text显示给用户编辑,用户修改后,把textbox的text赋值回给datarow,最后update dataset更新数据.
把你的控件 继承Panel类,而不要集成UserControl类。
你可以在集成Panel后,往Panel里面加一些你自己的方法或Control来实现你需要的功能。向里面拖控件的功能则由Panel来控制,你自己就不用管了。
添加一个TextBox控件(比如叫TextBox1)。
类似于Lable控件的功能,你可以修改TextBox控件的Text属性来达到目的:
不是在设计器里修改,而是在代码中用“TextBox1.Text="你想要显示的字符串";”这样的语句,这样就可以在程序运行时改变显示的内容。
设置或者取消星号,你可以通过代码修改TextBox1的PasswordChar属性,跟上面的是类似的:
在其他的控件的事件中比如Button的Click事件中修改——“TextBox1.PasswordChar="";//不显示***”
“TextBox1.PasswordChar="*(或者任何你想要的字符)";//显示为***”
至于什么时候改就完全随你的意思了。
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