• 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())

  • 相关阅读:
    python面向对象的3个特点
    Redis-哈希槽
    PEP8 Python 编码规范
    每个人都要对自己进行5 项必要投资
    机器码和字节码
    python优缺点分析及python种类
    Zookeeper安装及运行
    Zookeeper简介与集群搭建
    Nginx Linux详细安装部署教程
    Nginx代理功能与负载均衡详解
  • 原文地址:https://www.cnblogs.com/zqonline/p/1221915.html
Copyright © 2020-2023  润新知