The infragistic ultragrid control does not provide click cell events, but sometimes we need this event, so we have to write it ourselves:
-
- Use the mouseclick event of ultragrid to obtain the cell to be clicked, and then perform the required operations on the cell.
- 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 }
- 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 }
-
- 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.