User (Old forums)MemberFebruary 3, 2009 at 11:09 amPost count: 23064
I have a subclassed CellViewerManager and CellEditorManager that consists of a single-column grid containing a homogenous list of objects. I cannot figure out how to get cells that contain this grid to fire DragDrop events.
AllowDrop for the manager grids is set to true. I have tried adding the handler in the template when first creating the grid, the way that your DragDrop sample does. No dice. I have tried handling the DragDrop in the parent grid, without success. I have even tried adding the handler when SetControlValueCore is first called. That doesn’t work either. Any advice about where and how to handle this event in this context would be greatly appreciated.
Imported from legacy forums. Posted by Aaron (had 4002 views)User (Old forums)MemberFebruary 4, 2009 at 4:20 pmPost count: 23064
Have you tried to subscribe to the ActivatingControl/DeactivatingControl on the CellEditorManager of the column on which the grid is set? In those event handlers, you subscribe/unsubscribe to the DragDrop events of the grid, and they should then fire.
Imported from legacy forums. Posted by André (had 234 views)User (Old forums)MemberFebruary 4, 2009 at 6:11 pmPost count: 23064
I tried this, no luck. I tried subscribing to ActivatingControl both where the CellEditorManager is set and in the constructor of the CellEditorManager itself. In both cases I tried the following:
private void editor_ActivatingControl( object sender, CellEditorEventArgs e )
e.Control.DragDrop += new DragEventHandler( ctl_DragDrop );
e.Control.DragEnter += new DragEventHandler( ctl_DragEnter );
This fired neither event. I also tried subscribing to e.Cell.DragDrop and e.Cell.DragEnter, but those didn’t fire either.
Could the problem be that I am using my own subclassed version of the Xceed GridControl (which has its own handlers for DragDrop and DragEnter) as my base class for my TaskEditor subclass? Or am I subscribing to these events in the wrong place? Or what?
Thanks again for your patience with what are no doubt naive questions.
Imported from legacy forums. Posted by Aaron (had 497 views)User (Old forums)MemberFebruary 5, 2009 at 8:14 amPost count: 23064
Incidentally, I also tried getting these events to fire using one of your standard CellEditorManagers, a TextEditor, using the same strategies. That didn’t work for me either.
Imported from legacy forums. Posted by Aaron (had 257 views)User (Old forums)MemberFebruary 5, 2009 at 4:05 pmPost count: 23064
Here is how to subscribe to regular editors in the grid. It should be the same using your own editors.
For example, you need to subscribe to TextBox events through the ActivatingControl event of the CellEditorManager. This is necessary because the editor is actually initialized only when the cell receives focus, and enters the edit mode.
private void Form1_Load(object sender, System.EventArgs e)
gridControl1.Columns[ 0 ].CellEditorManager.ActivatingControl += new CellEditorEventHandler(CellEditorManager0_ActivatingControl);
gridControl1.Columns[ 0 ].CellEditorManager.DeactivatingControl += new CellEditorEventHandler(CellEditorManager0_DeactivatingControl);
private void CellEditorManager0_ActivatingControl(object sender, CellEditorEventArgs e)
( ( WinTextBox )e.Control).TextBoxArea.DoubleClick += new EventHandler(TextBoxArea_DoubleClick);
private void CellEditorManager0_DeactivatingControl(object sender, CellEditorEventArgs e)
//need to unsubscribe, if not, the subscriptions will kept pilling up!
( ( WinTextBox )e.Control).TextBoxArea.DoubleClick -= new EventHandler(TextBoxArea_DoubleClick);
private void TextBoxArea_DoubleClick(object sender, EventArgs e)
System.Diagnostics.Debug.WriteLine( sender.ToString() );
Imported from legacy forums. Posted by André (had 292 views)User (Old forums)MemberFebruary 5, 2009 at 4:51 pmPost count: 23064
The columns in my grid are created at runtime. Furthermore not every row in a column has the same CellEditorManager, and these too are set at runtime. So subscribing to the ActivatingControl and DeactivatingControl events of the CellEditorManager when the column is created, let alone when the form loads, will not work for me. Just as an experiment I tried subscribing on column creation, and neither Activating nor Deactivating fired, which is what I expected.
Instead I subscribed to the events when the Cell was populated and its CellEditorManager was set, like so:
private void setViewer( Cell pxCell )
if( needsCustomEditor( pxCell ) )
pxCell.CellViewerManager = new CustomViewer();
pxCell.ReadOnly = false;
pxCell.CellEditorManager = getCustomEditor();
pxCell.CellEditorDisplayConditions = CellEditorDisplayConditions.MouseOverCell;
private CellEditorManager getCustomEditor()
CustomEditor editor = new CustomEditor();
editor.ActivatingControl += new CellEditorEventHandler( editor_ActivatingControl );
editor.DeactivatingControl += new CellEditorEventHandler( editor_DeactivatingControl );
Inside editor_ActivatingControl and editor_DeactivatingControl I subscribe (and unsubscribe) to DragEnter and DragDrop, as shown in my previous post. In this scheme ActivatingControl and DeactivatingControl fire as expected. But DragEnter and DrapDrop do not fire.
A couple more points that may be significant. The grid in question is a DetailGrid. MouseClick and MouseDoubleClick are both subscribed to in the initialization code of the DetailGrid (as well as the parent), and they both fire exactly as you would expect them to. So this problem seems to pertain to drag events in particular.
Imported from legacy forums. Posted by Aaron (had 4062 views)User (Old forums)MemberFebruary 9, 2009 at 5:27 pmPost count: 23064
I’m not sure if the problem is with your inherited grid, but I have made a very simple sample application that shows the drag and drop events work when the grid is used within a cell. Find it attached to this post.
Imported from legacy forums. Posted by André (had 3733 views)
- You must be logged in to reply to this topic.