[quote=240308:@Bryan Dodson]I want to implement a popup menu that allows users to right click and paste in a listbox. I also want to allow this to happen under two conditions
If the user has clicked in the cell and the cell has focus
If the user is moving from another control, hovers over a cell, and right-clicks before the cell gets focus
[/quote]
Normally, when the cell is edited, the right click menu will offer to paste. This is the default. No need to add anything.
When the cell is edited I can use the default paste, but I also want to allow pasting with a right-click when the user hovers over a cell in the listbox without selecting the cell and entering edit mode.
[quote=240327:@Bryan Dodson]I am doing this in the mouseDown event.
When the cell is edited I can use the default paste, but I also want to allow pasting with a right-click when the user hovers over a cell in the listbox without selecting the cell and entering edit mode.[/quote]
You say it is working already, right ?
You cannot replace the content of the cell in code while it is edited. That is why you must use the default right click menu.
It works if the user is moving from another control, hovers over a cell, and right-clicks before the cell gets focus. It does not work if the cell is in edit mode. If I cannot replace the content of the cell while the cell is in edit mode, are there any work arounds?
I do things like this in the MouseDown event. Check for a right click with IsContextualClick and then stuff what I want in the cell I right-clicked on. I never go into edit mode for operations like this.
“I do things like this in the MouseDown event. Check for a right click with IsContextualClick and then stuff what I want in the cell I right-clicked on. I never go into edit mode for operations like this.”
I can do this if the user has not entered edit mode first. If the user has entered edit mode I cannot change the cell contents.
I am hoping someone on this board knows how to take the cell out of edit mode first? Or address MyGrid.ActiveCell.Text directly. Either way and my problem is solved.
[quote=240340:@Bryan Dodson]I am hoping someone on this board knows how to take the cell out of edit mode first?
[/quote]
me.SetFocus should work. At that point The ActiveCell TextField (or textArea) actually has the focus. Setting it back to the listbox will get you out of edit mode/
[/quote]
Or address MyGrid.ActiveCell.Text directly.
.[/quote]
I though that would work… I think I’ve done that in CellGotFocus. Never tried it in any other event for sure.