Hi,
I have an EditorButton that is an editor for a column in the grid. When user clicks on its right button I perform an action that requires current cell coordinates. This works as needed.Here is the code.
void IGBdfDetailsPopupEdit::ButtonEditClick(System::Object ^sender, Infragistics::Win::UltraWinEditors::EditorButtonEventArgs ^e) { UltraTextEditor ^btn = (UltraTextEditor^)sender; UltraGridCell ^cell = (UltraGridCell^)e->Context; CellUIElement ^element = (CellUIElement^)cell->GetUIElement(); currentRectangle = grid->NativeGrid()->RectangleToScreen(element->Rect); grid->CallPopup(this); // private method }
Now I need to have the same behavior when user presses F4 in the text editor. I cannot extract this method and reuse as I don't have a reference to the Context in that new method.
How would I simulate a click on the EditorButton/RightButton element. It doesn't have the PerformClick as the normal button has.
Thx
Hi Mitja,
Thank you posting in our forums.
If I understand your question correctly, it seems that you need to call the click method in order to get the cell (the Context) in which the TextEditor is used. If that is the case, then calling the click method is not necessary. You can get the currently active cell, by using the grid’s ActiveCell property. You can substitute the Context with this property and extract the method. The ActiveCell property will return the currently active cell or null if there isn’t such cell. You can check if the cell is in edit mode from its IsInEditMode property.
Please let me know if you have any additional questions.
That seems to work, but now I cannot catch the KeyDown event for that EditorButton. When is used as a standalone control the KeyDown event is fired, but when is inside the grid that event is not raised.
I know I can catch the KeyDown for the grid itself, but then how do I know if needed cell is being edited? So, question would be, how to tell the grid to bubble down the event to the editors and not eat it.
thx
Thx, that worked pretty good.
When the TextEditor isn’t standalone, i.e. it is used as an editor, it won’t receive the KeyDown events. You will need to use the KeyDown event of the grid itself. Again you can check which cell is being edited by using the ActiveCell property of the grid. Also note that you can get the cell’s editor by using its EditorResolved property, which you can use if you want to determine if the cell uses your editor.
Hopefully this way you will be able to determine if the cell edited is the needed cell. Let me know if you have any additional questions.