Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Thread Tools Display Modes
Old 11-23-2002, 01:24 AM
DJK DJK is offline
Senior Member
Join Date: Aug 2002
Posts: 1,379
Default Move line solution ?

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 )
Reply With Quote
Old 11-23-2002, 05:02 AM
simes simes is offline
Senior Member
Join Date: Jan 2002
Posts: 2,327
Default RE: Move line solution ?

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.

Please click accept if this helps

SadMan Software
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump

All times are GMT. The time now is 11:51 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2018, vBulletin Solutions, Inc.