Board index » delphi » String Grid Row Moving Special Action

String Grid Row Moving Special Action

Hi,

D5

I have several string grids on separate tabsheets and I would like to move a
row from the current grid to another grid by seleting the row and dragging
and dropping it on a tab representing a different sheet ( ie different
grid). I also want to be able to move rows around on their own grids.

Grids have no fixed columns,
    goRowselect=true
    goRangeSelect=false

Is this doable?

I have tried all combinations of options etc and drag mode.

Thanks
Ian

 

Re:String Grid Row Moving Special Action


Quote
In article <3bf8c7c7$1_2@dnews>, Ian Bainbridge wrote:
> I have several string grids on separate tabsheets and I would like to move a
> row from the current grid to another grid by seleting the row and dragging
> and dropping it on a tab representing a different sheet ( ie different
> grid). I also want to be able to move rows around on their own grids.
> Is this doable?

I think so. YOu will need OnDragOver and OnDragDrop handlers on both the
pagecontrol (the tabs belong to the pagecontrol, not the tabsheets) and each
grid. In the pagecontrols OnDragOver handler you would use the IndexOfTabAt
method to find the tab under the mouse and decide on whether its allowable to
drop there or not. The ondragDrop handler would then copy the source row to
the grid on the target tabsheet. For a drag inside a grid you can use the
MouseToCell method to identify the row dragged to and the MoveRow method to
move the dragged row. I don't know whether the build-in dragging of rows would
be compatible with dragging outside the grid, you have to test that. It needs
a fixed column anyway, if memory serves.

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!
Note: I'm unable to visit the newsgroups every day at the moment,
so be patient if you don't get a reply immediately.

Re:String Grid Row Moving Special Action


Thanks Peter,

I will give it a go.

Would it be difficult to apply the auto scrolling when the dragging moves
off the control (top or bottom)?

Ian

Re:String Grid Row Moving Special Action


Quote
In article <3bf9f15c$1_1@dnews>, Ian wrote:
> Would it be difficult to apply the auto scrolling when the dragging moves
> off the control (top or bottom)?

If you find that the build-in row drag works for you it would cut in
automatically. If not you have to scroll the grid in code.

The usual technique is to define a "hot zone" of a few pixels on top and
bottom of the client area. When the mouse enters this area while dragging
you start a timer with a fuse of a couple of 100 msecs (depends on how fast
you want to scroll) and on each timer event you

 - test if the mouse button is still down, if not stop the timer and exit
 - test if the mouse is still in the hot zone or outside the target control
   in the correct direction. if not stop the timer and exit
 - if the tests pass you scroll the control one item

The timer is stopped when the drag ends or the user leaves the hot zone
towards the interior of the control.

Doing it this way results in a regular scrolling even if the user does not
move the mouse. DragOver or Mousemove events only happen when the mouse is
moved. You can scroll about any control by sending it WM_VSCROLL messages.
For a grid you could also set the TopRow property to scroll it.

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!
Note: I'm unable to visit the newsgroups every day at the moment,
so be patient if you don't get a reply immediately.

Re:String Grid Row Moving Special Action


Thanks Again Peter

Ian

Other Threads