Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All,

I have one page with GridView. Now I wanted to drag and drop of rows. I have searched and found some articles and in that they have given MouseEventArgs... I am not getting those Args in my web page. Do I need to add any thing to get MouseEventArgs on my web page?.

C#
private void dataGridView1_MouseMove(object sender, MouseEventArgs e)
{
    if ((e.Button & MouseButtons.Left) == MouseButtons.Left)
    {
        // If the mouse moves outside the rectangle, start the drag.
        if (dragBoxFromMouseDown != Rectangle.Empty &&
            !dragBoxFromMouseDown.Contains(e.X, e.Y))
        {

            // Proceed with the drag and drop, passing in the list item.
            DragDropEffects dropEffect = dataGridView1.DoDragDrop(
                     dataGridView1.Rows[rowIndexFromMouseDown],
                     DragDropEffects.Move);
        }
    }
}


Any suggestions please...

Thanks
Naveen.
Posted

1 solution

The reason MouseEventArgs is not working is it is available in Forms application...
since you are using it in web application, it gives you error...

For drag and drop behavior in Web app, you can use JQuery and here are some links...

http://csharpdotnetfreak.blogspot.com/2012/07/drag-drop-gridview-rows-jquery-aspnet.html[^]

http://isocra.com/2008/02/table-drag-and-drop-jquery-plugin/[^]
 
Share this answer
 
Comments
NaVeN Kumar 8-May-13 2:27am    
Thanks for the info...
Naz_Firdouse 8-May-13 3:02am    
Please mark it as answer for future users...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900