Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
620
How to get target row index drag-dropped on in UltraGrid
posted

Hi, I am doing a drag and drop implementation from one UltraGrid to another, updating just one particular cell.

How can I find out the index of the row in the target grid the user dropped onto?

The following works great if I put a fixed index, but that of course is not the idea.

 

 

 

 

 

 

 

private void ultraGridTarget_DragDrop(object sender, DragEventArgs

e)

{

 

 

 

SelectedRowsCollection selRows = (SelectedRowsCollection)e.Data.GetData(typeof(SelectedRowsCollection

));

 

 

 

//UltraGrid is configured so user can only select (and therefore dragdrop) single rows.

 

 

 

string valueString = selRows[0].Cells["Description"

].Value.ToString();

dataTableTarget.Rows[INDEX OF ROW USER DROPPED ON][

 

 

"Description"

] = valueString;

Parents
No Data
Reply
  • 620
    Verified Answer
    posted

    OK, I think I found it. You have to do it in the time-honored Windows fashion. I thought there might be a more direct way.

    int dropIndex;
    UltraGrid dropGrid = sender as UltraGrid;
    UIElement uieOver = dropGrid.DisplayLayout.UIElement.ElementFromPoint(dropGrid.PointToClient(new Point(e.X, e.Y)));
    UltraGridRow ugrOver = uieOver.GetContext(typeof(UltraGridRow), true) as UltraGridRow;
    if (ugrOver != null)
    {
       dropIndex = ugrOver.Index;

     

    It's working for me, so I guess I answered my own question.

Children
No Data