我正在创建一个wpf应用程序,但是我似乎无法处理用户控件的事件 在mainwindow.axml中,我创建了一个Windowsformhost,并在运行时完美加载了内容(加载数据集的数据等),但是我该如何处理鼠标或键盘按下的事件呢?
在用户控件中:
Public Event DOBLECLICK()
Public Sub sp1_CellDoubleClick(sender As Object, e As
FarPoint.Win.Spread.CellClickEventArgs) Handles sp1.CellDoubleClick
RaiseEvent DOBLECLICK()
End Sub
在主窗口中: 我尝试加载事件,但似乎没有响应。
Private Sub WinFormsHost_MouseLeftButtonUp(sender As Object, e As
MouseButtonEventArgs) Handles WinFormsHost.MouseLeftButtonUp
AddHandler host.sp1.CellDoubleClick, AddressOf host.sp1_CellDoubleClick
End Sub
Private Sub Control_MouseDoubleClick_1(sender As Object, e As MouseEventArgs)
AddHandler host.sp1.CellDoubleClick, AddressOf host.sp1_CellDoubleClick
End Sub
答案 0 :(得分:0)
在(λ (x) (polyX x))
函数中,添加以下内容:
MainWindow_Loaded
然后在您的类中创建一个新函数(双击单元格时会调用该函数。在此之后不要使用AddHandler host.sp1.CellDoubleClick, AddressOf host.sp1_CellDoubleClick
,因为您已经在Handles
中添加了该处理函数):>
MainWindow_Loaded
不需要功能Public Sub sp1_CellDoubleClick(sender As Object, e As FarPoint.Win.Spread.CellClickEventArgs)
RaiseEvent DOBLECLICK()
End Sub
和WinFormsHost_MouseLeftButtonUp
。您可以删除它们。