I have this event handler bound to my listview
我将此事件处理程序绑定到listview
ListView1.ColumnWidthChanged
And I have this function which alters my columns' dimensions executed right after feeding my list with data.
我有这个功能,它可以在我的列表中提供数据后立即改变我的列的维度。
ListView1.AutoResizeColumns
I want to know if there is a way to suspend VB from firing an event after an automatic sorting ? I mean anything but manual intervention ?
我想知道是否有办法暂停VB在自动排序后触发事件?我的意思是手动干预除了什么?
I though about setting a global variable but this takes much work and can be imprecise, also event args parameter doesn't encompass anything implicit that handles a mouse event, Is there any way through ?
我虽然设置了一个全局变量,但这需要很多工作并且可能不精确,而且event args参数不包含任何处理鼠标事件的隐式变量,有没有办法解决?
This is what I have tried so far about mouse event handling:
这是我迄今为止尝试过的关于鼠标事件处理的内容:
Sub listview1mousedown(sender As Object, e As EventArgs) Handles ListView1.MouseMove
AddHandler ListView1.ColumnWidthChanged, AddressOf resizetable
End Sub
Sub listview1mouseup(sender As Object, e As EventArgs) Handles ListView1.MouseLeave
RemoveHandler ListView1.ColumnWidthChanged, AddressOf resizetable
End Sub
Is there any peer solution concerning events triggered by other means rather than mouse ?
关于由其他方式而不是鼠标触发的事件是否有任何同行解决方案?
1 个解决方案
#1
0
Found it finally, ....
终于找到了,....
Appearently setting cursor event catch doesn't work literally at the header's level, the function doesn't fire any event when the mouse gets off the higher bound of subitem collection's container, therefor I managed te set focus event listener to catch mouse focus on the listview, this is enough user defined behavior for me:
显然设置游标事件catch在字头的级别上不起作用,当鼠标离开子项集合的容器的上限时,该函数不会触发任何事件,因此我管理te set焦点事件监听器以捕获鼠标焦点listview,这对我来说是足够的用户定义行为:
I set:
AddHandler CType(list, ListView).GotFocus, Sub()
AddHandler CType(list, ListView).ColumnWidthChanged, AddressOf resizetable
Debug.Print("handler on")
End Sub
AddHandler CType(list, ListView).LostFocus,Sub()
RemoveHandler CType(list, ListView).ColumnWidthChanged, AddressOf resizetable
Debug.Print("handler off")
End Sub
Then i wrote in my Main()
:
然后我在我的Main()中写道:
Public Function resizetable( table As listview, e As columnwidthchangedeventargs)
'... core of the event handler
Debug.Print("Listview column width changed")
End Function
So i ran my app in debug mode and proceeded to adjust my column size manually, then I saw this in my debug console:
所以我在调试模式下运行我的应用程序并继续手动调整列大小,然后我在调试控制台中看到了这个:
handler on
Listview column width changed
列表视图列宽已更改
handler off
I ran this inside main()
:
我在main()中运行了这个:
list.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent)
Nothing appeared in my output !!!! I think I got it right. thanks to everyone for their deliberate advices.
我的输出中没有出现任何东西!!!!我想我做对了。感谢大家的慎重建议。
#1
0
Found it finally, ....
终于找到了,....
Appearently setting cursor event catch doesn't work literally at the header's level, the function doesn't fire any event when the mouse gets off the higher bound of subitem collection's container, therefor I managed te set focus event listener to catch mouse focus on the listview, this is enough user defined behavior for me:
显然设置游标事件catch在字头的级别上不起作用,当鼠标离开子项集合的容器的上限时,该函数不会触发任何事件,因此我管理te set焦点事件监听器以捕获鼠标焦点listview,这对我来说是足够的用户定义行为:
I set:
AddHandler CType(list, ListView).GotFocus, Sub()
AddHandler CType(list, ListView).ColumnWidthChanged, AddressOf resizetable
Debug.Print("handler on")
End Sub
AddHandler CType(list, ListView).LostFocus,Sub()
RemoveHandler CType(list, ListView).ColumnWidthChanged, AddressOf resizetable
Debug.Print("handler off")
End Sub
Then i wrote in my Main()
:
然后我在我的Main()中写道:
Public Function resizetable( table As listview, e As columnwidthchangedeventargs)
'... core of the event handler
Debug.Print("Listview column width changed")
End Function
So i ran my app in debug mode and proceeded to adjust my column size manually, then I saw this in my debug console:
所以我在调试模式下运行我的应用程序并继续手动调整列大小,然后我在调试控制台中看到了这个:
handler on
Listview column width changed
列表视图列宽已更改
handler off
I ran this inside main()
:
我在main()中运行了这个:
list.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent)
Nothing appeared in my output !!!! I think I got it right. thanks to everyone for their deliberate advices.
我的输出中没有出现任何东西!!!!我想我做对了。感谢大家的慎重建议。