
代码如下:
Partial Public Class MainPage
Inherits UserControl
Private currentlocation As Point
Public Sub New()
InitializeComponent()
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click
Label1.Content = "您好," & TextBox1.Text & "!"
End Sub
Private Sub LayoutRoot_MouseMove(sender As System.Object, e As System.Windows.Input.MouseEventArgs) Handles LayoutRoot.MouseMove
currentlocation = e.GetPosition(LayoutRoot)
Label2.Content = "现在鼠标的坐标是:(" & currentlocation.X.ToString() & "," & currentlocation.Y.ToString() & ")"
End Sub
End Class
移动发生在MouseMove事件中,而单击发生在Button1_Click中,click事件只适用于button控件
本文介绍了一个使用VB.NET编写的简单示例程序,该程序演示了如何通过按钮点击改变标签文本,以及如何捕捉鼠标移动事件并在另一个标签上显示当前鼠标位置坐标。
1395

被折叠的 条评论
为什么被折叠?



