Hi there,
I'd like to have spellchecking in a selected gridcell, where, when right-clicking a ContextMenu should appear with suggestions. In the code below I attach an UltraSpellChecker to an ActiveCell:
private void UltraGrid_AfterCellActivate(object sender, EventArgs e)
{
customEditor.SpellChecker = ultraSpellChecker;
customEditor.ContextMenuStrip = spellingMenuStrip;
ultraGridActiviteitenEnTaken.ActiveCell.EditorControl = customEditor;
}
The spellchecking seems to work, but the MouseDown event does not fire when I (right)click the ActiveCell. Does someone have a solution to this problem?
Ruud
Hi Matt,
The PerformAction was not ment to invoke a MouseDown event, but only to put the ActiveCell into Edit mode (whereafter I did some mouse clicking myself )
I have implemented the UltraTextEditor in the way you suggested, but still the MouseDown doesn't fire when I click within the ActiveCell [:'(] Within a plain UltraTextEditor it works fine, but not when this TextEditor is coupled to the UltraGrid. I guess this has to do with fact that EditorControl is of type Control whereas UltraTextEditor is more specific... Hence, my problem seems to be more general:
How to couple my MouseDown handler to the ActiveCell, such that when I click within the ActiveCell the event is fired and handled by my handler? I tried to couple my handler to the MouseDown event of the EditorControl but this doesn't work... Important to note: it doesn't have to be an UltraTextEditor; if I can use the default editor I'd be more than glad!
I hope this this 'story' clarifies the problem...
-Ruud-
Ruud,
No, the MouseDown won't fire when calling PerformAction since you're not using the mouse . Why not take the approach I suggested of setting the relevant EditorControl property on the column instead, so that you can do all your initialization logic there instead of trying to work out these odd timing issues with your current approach?
-Matt
Thanks for your quick reaction! Indeed, my method is somewhat inefficient, but it was only for testing... I did already suspect that the ActiveCell was not in Edit mode, but I don't know how to get it into Edit mode. I tried
UltraGrid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode);
but this doesn't work (at least the MouseDown event doesn't fire). Is there a way to put the UltraTextEditor within the ActiveCell into Edit mode so that the event does fire?
Greets,
What is happening is that the cell is not in edit mode yet, so the TextBox will not be positioned yet and therefore will not receive the MouseDown message. With this being said, your approach seems to be pretty inefficient; every time that a cell is activated, you are creating a completely new control and assigning it to that editor. Why not create a single instance of the control and then assign it to the column in the InitializeLayout event? Alternatively, you could assign it to individual cells in the InitializeRow event.