TextBox Clear ( ) 清除TextBox 组件的显示内容MsgBox ( 失去焦点! ) 弹出提示框
至此【TextBox组件】项目的全部工作就完成了 图 是程序编译后运行界面
图 【TextBox项目】的运行界面
lishixinzhi/Article/program/net/201311/12721
vb.net 窗口控件的制作把你的控件 继承Panel类,而不要集成UserControl类 。
你可以在集成Panel后,往Panel里面加一些你自己的方法或Control来实现你需要的功能 。向里面拖控件的功能则由Panel来控制,你自己就不用管了 。
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
自已用 VBNET 2010 做的控件,想添加一个开发模式下的右键菜单如何做?那个绝对不是自定义控件vbnet控件开发,这东西叫ContextMenuStripvbnet控件开发 , 把背景和图片处理一下,然后右键显示,在鼠标位置显示代码如下vbnet控件开发:
private void C1FlexGrid1_MouseDown(object sender, MouseEventArgs e)
{
if (MouseButtons == MouseButtons.Right)
{
Point p = new Point();
p.X = e.Location.X + this.Location.X + 20;
p.Y = e.Location.Y + this.Location.Y + 150;
this.contextMenuStrip1.Show(p);
}
}
你那个第三方控件,C1FlexGrid倒真是个自定义控件,是重写dataGridView做vbnet控件开发的,至于菜单嘛,那个绝对不叫属性,是自己设置的按钮,背景图片画得漂亮点而已,这个跟VB6.0还是有点区别的
VB.net程序开发的时候 。界面开发所有的控件位置都是手动的方式用对齐来确定位置吗?有两种解决方法
推荐阅读
- 即时策略单机游戏手游推荐,即时策略类游戏简写
- 最厉害的电视是什么电视,最牛的电视剧
- 现在角色扮演的游戏,现在角色扮演游戏哪个好玩
- 开直播要什么手机好用,开直播要什么手机好用一点
- phpsql数据库连接 php连接数据库mysql
- mysql数据库商用,mysql商城数据库表设计
- ppt如何排序,ppt如何排序文字出场顺序
- php好还是数据库 php和sql区别
- 尖草坪区如何全网推广,尖草坪区改造最新