Consultor Eletrônico



Kbase P152879: How to retrieve the cell where the mouse click event was fired in an UltraGrid?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   17/09/2009
Status: Unverified

GOAL:

How to retrieve the cell where the mouse click event was fired in an UltraGrid?

GOAL:

How to get the cell and column in a UltraGrid's click event?

FACT(s) (Environment):

OpenEdge 10.2A
Windows

FIX:


The following samples assumes that the cells' CellClickAction in UltraGrid is set to RowSelect which causes
an entire row in UltraGrid to be selected when user click any cell. The task is to find what cell and row were the source of the click event.
METHOD PRIVATE VOID ultraGrid1_Click( INPUT sender AS System.Object, INPUT e AS System.EventArgs ):

DEF VAR UIelem AS Infragistics.Win.UIElement.
DEF VAR mPoint AS System.Drawing.Point.
def var eMouse as System.Windows.Forms.MouseEventArgs.

/* UltraGrid column */
def var ucol as Infragistics.Win.UltraWinGrid.UltraGridColumn.
def var ucell as Infragistics.Win.UltraWinGrid.UltraGridCell.

eMouse = CAST( e, "System.Windows.Forms.MouseEventArgs" ).
mPoint = eMouse:Location.

UIelem = CAST( ultraGrid1:DisplayLayout:UIElement:ElementFromPoint( mPoint ),
"Infragistics.Win.UIElement" ).

/* get the column where the mouse click was */
ucol = CAST( UIelem:GetContext()
, "Infragistics.Win.UltraWinGrid.UltraGridColumn" ).

/* get the cell where the mouse click was */
ucell = ultraGrid1:ActiveRow:Cells[ucol:ToString()].

message ucol:ToString()
ucell:Value:ToString()
view-as alert-box.

RETURN.

END METHOD.