This is a migrated thread and some comments may be shown as answers.

Drag & Drop on grouped GridView

1 Answer 48 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Thomas Van den Bossche
Top achievements
Rank 1
Thomas Van den Bossche asked on 14 Oct 2009, 10:25 AM
Dear,

I have a question regarding drag & drop on a grouped GridView.
The drag & drop functionality (drag & drop between two GridViews) works but now I want to drag on the header of a group.
I need to get the ID or text of the header group.

private void gridAssigned_DragDrop( object sender, DragEventArgs e ) { 
            if ( e.Data.GetDataPresent( typeof( GridViewDataRowInfo ) ) ) { 
                // dropped on which group? 
                // need ID or text... 
                GridViewRowInfo droppedDriver = GetRowAtPoint( gridAssigned, gridAssigned.PointToClient( new Point( e.X, e.Y ) ) ); 
                // row I'm dragging 
                GridViewDataRowInfo draggedInfo = ( GridViewDataRowInfo )e.Data.GetData( typeof( GridViewDataRowInfo ) ); 
            } 
        } 
 
private GridViewRowInfo GetRowAtPoint( RadGridView grid, Point location ) { 
            RadElement element = grid.ElementTree.GetElementAtPoint( location ); 
 
            // headercells are for grouping 
            if ( element is GridHeaderCellElement ) { return null; } 
            if ( element is GridCellElement ) { return (( GridRowElement )element).RowInfo; } 
 
            return null
        } 

Thanks in advance!

1 Answer, 1 is accepted

Sort by
0
Accepted
Jack
Telerik team
answered on 15 Oct 2009, 08:49 AM
Hi Thomas,

Thank you for contacting us. You can use code similar to this one:

void radGridView1_MouseDown(object sender, MouseEventArgs e)
{
    GridCellElement cell = this.radGridView1.ElementTree.GetElementAtPoint(e.Location) as GridCellElement;
    if (cell != null)
    {
        GridViewGroupRowInfo groupRow = cell.RowInfo as GridViewGroupRowInfo;
        if (groupRow != null)
        {
            string text = groupRow.GetSummary();
            //...
        }
    }
}

If you have more questions, please write me back.

Greetings,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Thomas Van den Bossche
Top achievements
Rank 1
Answers by
Jack
Telerik team
Share this question
or