Link to home
Start Free TrialLog in
Avatar of feckless
feckless

asked on

urgent!!!how can i move a row up and down in the same datawindow?

pls help me !
i am so anxious to kown how i can move the row freely
in the same dw!
Avatar of Bhatti
Bhatti

Hi Feckless,

Use the RowsMove() function to move the row.

dw_1.RowsMove(startrow, endrow, buffer!, targetdw, beforerow, targetbuffer)

dw_1.RowsMove(2, 2, Primary!, dw_1, 23, Primary!)

Use both time the same dw_name. start and end rows the row rows you want to move.
Target dw the datawindow where you wamt to move. and of course before which row you want to insert.
and buffer.

Try it, will help you.
Avatar of feckless

ASKER

how can i drag the row up and dowm with a mouse
i don't know how to make the mouse in the status
of draging and droping
Hi feckless:

I'm sure there is a more "professional" way to do this, but this is the "fast-nasty" way i do what you want to do (think so).

You need to declare a long instance variable to store the origin row, lets name it or_row.

In the datawindow events:

clicked
   or_row = row
   drag(begin!)

dragwithin
   selectrow(0, false)
   selectrow(row, true)

dragdrop
   rowsmove(or_row, or_row, primary!, this, row, primary!)

Remember to disable the option dragauto in the dw prorperties.

And that's all, of course, some error detection (like verify you clicked a row > 0 and you drop it in a row > 0) should help too. Note that rowsmove drops the row BEFORE the target.

Hope it helps!
ASKER CERTIFIED SOLUTION
Avatar of Bhatti
Bhatti

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hello,

I forget last time to write the extention in Dragwithin EVENT;

Please the last two lines changed with these lines to avoid the selection of all lines.

if dwo.name = 'datawindow' then
   Selectrow(0, false)
else
   selectrow(0, false)
   selectrow(row, true)
end if

Moreover, I wrote two time dragwithin Event but you need last one, it  is the right one.

Hello Feckless,

I am setting the complete script here, because it is now in two parts and I want to set these two parts in one part.

Instance variable il_currentrow, il_row and il_checkrow

=============================================================
************************
clicked Event
 ************************

IF row > 0 then
    il_row = row
    selectRow(0, false)
    selectrow(row, true)
     this.Drag(Begin!)
end if

****************************
 DragDrop Event
****************************

dw_1.drag(End!)


if il_row > row then dw_1.RowsMove(il_row, il_row, Primary!, dw_1, row , Primary!)
if il_row < row then dw_1.RowsMove(il_row, il_row, Primary!, dw_1, row + 1, Primary!)

selectrow(0, false)
selectrow(row, true)

//or you can adjust with selectrow(row - 1, true) and so on
//row you can adjust yourself where you want to paste.

****************************
Scrollvertical Event
****************************

string ls_lastrow

ls_lastrow = dw_1.Object.Datawindow.LastRowOnPage
il_flag = integer(ls_lastrow)

RETURN 0

**********************************
Dragwithin Event
**********************************

long ll_row

st_1.Text = string(il_flag)
il_currentrow = row
if row = 0 then selectrow(1, true)    
if row > il_flag - 2 then
   il_currentrow++
   scrolltorow(il_currentrow)
   st_2.text = string(ll_row)
else
   if il_currentrow > 0 then
       il_currentrow = il_currentrow - 1
       scrolltorow(il_currentrow)
   end if
end if
if dwo.name = 'datawindow' then
   selectrow(0, false)
else
   selectrow(0, false)
   selectrow(row, true)
end if
=============================================================

I set the complete script here. It is working good.

Please let me know.

THANKS
Force Accepted

SpideyMod
Community Support Moderator @Experts Exchange