Home Forums WinForms controls Xceed Grid for WinForms Drag/drop events in custom CellViewerManager and CellEditorManager

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #16807 |

    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.

     

    Best regards,

    Aaron Haspel

    Imported from legacy forums. Posted by Aaron (had 4002 views)

    User (Old forums)
    Member
    Post 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)
    Member
    Post 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.

     

    Aaron Haspel

     

     

     

    Imported from legacy forums. Posted by Aaron (had 497 views)

    User (Old forums)
    Member
    Post 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)
    Member
    Post 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.

    e.g.:

    //at Form_Load

        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);

    //Event handlers

        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)
    Member
    Post 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 );
                return editor;
            }

     

    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. 

    Aaron

     

     

     

    Imported from legacy forums. Posted by Aaron (had 4062 views)

    User (Old forums)
    Member
    Post 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)

    User (Old forums)
    Member
    Post count: 23064

    Appreciated. I downloaded your sample and played around with it a bit, and it pointed me in the right direction.

    AH

    Imported from legacy forums. Posted by Aaron (had 4444 views)

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.