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

Row Reorder Event

1 Answer 157 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Eric
Top achievements
Rank 1
Eric asked on 14 Sep 2012, 01:56 PM
Is there any way to catch a row reorder event?

My grid is in unbound mode, with AllowRowReorder = true.  I need to be able to tell when a user reorders the rows via drag and drop, but the obvious DragDrop event is not hit.  Do I really need to use MouseDown, MouseUp, and lots of calculations of row size and position?


-----------------------------------------------------------

Since posting this I found my answer in your demo:

...
 this.radGridView1.Rows.CollectionChanged += new NotifyCollectionChangedEventHandler(Rows_CollectionChanged);
...

 private void Rows_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
if (e.Action == NotifyCollectionChangedAction.Move)
{
for (int i = 0; i < this.radGridView1.Rows.Count; i++)
{
this.radGridView1.Rows[i].Cells["Priority"].Value = i + 1;
}
}
}

1 Answer, 1 is accepted

Sort by
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 07 Nov 2012, 12:47 PM
Hello Eric,

I made a code library project a while back that handles drag drop in bounded mode,

If you will require anything more complex than your example here, please take a look at that one for inspiration.

If you have any other questions, please let me know.

Best Regards,
Emanuel Varga
Winforms MVP
Tags
GridView
Asked by
Eric
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Share this question
or