随笔 - 76, 文章 - 3, 评论 - 34, 引用 - 0
数据加载中……

UltraGrid WinForms下,进行双击的一个问题。

正在状态下双击没有任何问题,如果用户在进行滚动条,滚动时,因引发双击事件,而影响用户操作。

下面这段代码,是处理这个问题的。在官方网站上找到。

  'Cast the sender into an UltraGrid
Dim grid As UltraGrid = DirectCast(sender, UltraGrid)

'Get the last element that the mouse entered
Dim lastElementEntered As UIElement = Me.UltraGrid1.DisplayLayout.UIElement.LastElementEntered

'See if there's a RowUIElement in the chain.
Dim rowElement As RowUIElement
If TypeOf lastElementEntered Is RowUIElement Then
rowElement = DirectCast(lastElementEntered, RowUIElement)
Else
rowElement = DirectCast(lastElementEntered.GetAncestor(GetType(RowUIElement)), RowUIElement)
End If

If rowElement Is Nothing Then Return

'Try to get a row from the element
Dim row As UltraGridRow = DirectCast(rowElement.GetContext(GetType(UltraGridRow)), UltraGridRow)

'If no row was returned, then the mouse is not over a row. 
If (row Is Nothing) Then Return

'The mouse is over a row. 

'This part is optional, but if the user double-clicks the line 
'between Row selectors, the row is AutoSized by 
'default. In that case, we probably don't want to do 
'the double-click code.

'Get the current mouse pointer location and convert it
'to grid coords. 
Dim MousePosition As Point = grid.PointToClient(Control.MousePosition)

'See if the Point is on an AdjustableElement - meaning that
'the user is clicking the line on the row selector
If Not lastElementEntered.AdjustableElementFromPoint(MousePosition) Is Nothing Then Return

'Everthing looks go, so display a message based on the row. 
MessageBox.Show(Me, "The key of the row is:" + row.Cells(0).Value.ToString())

posted on 2008-06-14 16:25 zqonline 阅读(40) 评论(0)  编辑 收藏 网摘 所属分类: 其它


标题  
姓名  
主页
Email (博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
Google站内搜索

相关文章:

相关链接: