![]() |
|
#1
|
|||
|
|||
|
I have beent hinking, I asked in one of my previous questions if it was possible to have a button that moved a line in a DBGrid one "up", or one "down" from it's current position in the Grid..
This was said to be impossible, but after some thinking can't you do something like this : Let's say I have : Item 1 Item 2 Item 3 Item 4 Now when I select line 3 (which is 'Item3') it should go one up, now one up equales moving positions with 'Item 2'.. so can't it be done this way ? : If button clicked Check what line is selected (line 3 in this ex) Copy content of line that's selected to temp place Move selected line -1 (which then is line2) to selected line Move content from temp place to selected line -1 I hoep you get what I mean you take the line that needs to go up, move it somewhere temporary, then move the line above it to the line that has to go up and then move the stuff in temporary to where the line you moved below was........ heh still looks compliated (my explenation )
|
|
#2
|
|||
|
|||
|
SQL DB tables don't have any order implied in the data, unless you use the ORDER BY clause. Changing the data as you explain, may not have the desired effect - it might put both rows at the end of the table for example
Also, depending upon the table structure, it might not allow you to do it at all, because at one point the same record is in the table twice, i.e. when you copy (or "move") the first record to the different place. If your table has an identity field, and you're displaying in the identity order, you may be able to update both rows as you describe, otherwise I doubt it. Sorry. Simon SadMan Software http://www.simes.clara.co.uk |
![]() |
| Thread Tools | |
| Display Modes | |
|
|