I am new to this forum and pretty new to VB.net and application development. I am trying to develop a scheduler for my workplace for which I am using a datagridview. The data displayed in the datagridview is bound to a SQL server database.
I need to be able to drag and drop rows so that the any job with a high priority and a nearer deadline can just be dragged from anywhere in the grid and dropped to the topmost point in the grid. I don't mind using two buttons (up and down) to do it either. But I am not able to figure out a way to do it.
Any kind of help would be appreciated. please let me know if you need any other information.
The attached project which was done by someone else, do not remember where I located it as it was sometime ago. I did tweak it a tad bit and marked where I did changes along with adding a module for language extensions.
Any ways you can drag and drop rows but has some issues which should be fixable like if the DataGridView is sorted by the user the operation does not work and sometimes it seems unnatural doing the drag drop. If you are willing to work with it I am sure it will provide what you need although I would feel more comfortable using the logic with buttons to move a row up/down.
That worked well.. thanks a lot! Although for some reason when I use that in my application... there is a weird increment in the position at which the row is dragged and dropped.
Like when I run it, the first time I do a drag drop .. it correctly does it at the position told. In the same instance, if i do a drag drop 2nd time, it drops the row 1 row above the position where I actually drop it. 3rd time... 2 rows above the position .. and that increases. do you know why?
That worked well.. thanks a lot! Although for some reason when I use that in my application... there is a weird increment in the position at which the row is dragged and dropped.
Like when I run it, the first time I do a drag drop .. it correctly does it at the position told. In the same instance, if i do a drag drop 2nd time, it drops the row 1 row above the position where I actually drop it. 3rd time... 2 rows above the position .. and that increases. do you know why?
I tried to reproduce what you had happen but could not. What I can say is that drag-drop takes some getting use too in a DataGridView in this manner.
I finally was able to do it correctly.. I also ended up adding couple more functionalities like cutting and pasting of rows. Thanks a lot for your help.
But there is one last thing that I am not able to do. Once you are done with the reordering of rows.. how do you post it back to the database? I am using multiple tables .. I used the update command and several parameters.. i am able to post back any changes I do except the change in ordering of rows.