Use uielement to get the mouse and click ultratedcell & add tooltip to ultratedcell

Source: Internet
Author: User

The infragistic ultragrid control does not provide click cell events, but sometimes we need this event, so we have to write it ourselves:

  1. Use the mouseclick event of ultragrid to obtain the cell to be clicked, and then perform the required operations on the cell.
  2. MouseclickCode 1 Private   Void Ultrabod=mouseclick ( Object Sender, mouseeventargs E)
    2 {
    3 Uielement mainelement = (Iultracontrolelement) ultrabod1). mainuielement;
    4 Ultrabodcell Cell =   Null ;
    5 // You can define what you want, such as ultrabdcell, ultrabacloud Drow, ultrabdcolumn or columnheader
    6 // Ultraman Drow ROW = NULL;
    7 Uielement = Mainelement. elementfrompoint ( New Point (E. X, E. y ));
    8 While (Element ! =   Null   && Cell =   Null ) // Replace cell with row, column or column header
    9 {
    10 Cell = Preparecell (element );
    11 // Row = preparerow (element );
    12 If (Cell =   Null ) // Replace cell with row, column or column header
    13 Element = Element. parent;
    14 }
    15 If (Cell =   Null )
    16 Return ;
    17 // Here you get the cell you need, then you can do any thing you want
    18 }
  3. Preparecell code 1 // Use the same way to get ultratedrow or ultratedcolumn, etc.
    2 Ultrabodcell preparecell (uielement element)
    3 {
    4 // Cast the uielement to the specified element you want
    5 Celluielement cellelement = Element As Celluielement;
    6 If (Cellelement =   Null )
    7 Return   Null ;
    8 // Get the context from the element
    9 Ultrabodcell Cell = Cellelement. getcontext ( Typeof (Ultrabodcell )) As Ultrabodcell;
    10 Return Cell;
    11 }
  4. You can use the same method when you need to add tooltip to ultrabodcell, but it is necessary to implement the mousemove and mouseleave event.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.