zoukankan      html  css  js  c++  java
  • 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())

  • 相关阅读:
    宠物收养场 Treap
    最佳课题选择
    [USACO08JAN]手机网络Cell Phone Network
    [USACO09MAR]地震损失2Earthquake Damage 2
    字符串距离 简单DP
    小行星群 网络流 二分图
    游览牧场 最小费用流
    BZOJ1391: [Ceoi2008]order
    BZOJ1570: [JSOI2008]Blue Mary的旅行
    BZOJ2243: [SDOI2011]染色
  • 原文地址:https://www.cnblogs.com/zqonline/p/1221915.html
Copyright © 2011-2022 走看看