We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

# Delphi Programming question

on
Medium Priority
222 Views
Hello!
Using TStringGrid component I want to move more than
one row in the grid.
How can I do that with D1?

Thanks,
Tom

P.S.
Hello Ian!
Moving in my problem means I select more than 1 row in the StringGrid and like to move them lets say 1..n row to the top or
the bottom of the grid e.g. rows 10..15 are selected and I want to move them to row 2..7!!

Tom

Comment
Watch Question

## View Solution Only

Commented:
Unless you're a bit more clear, your probably gonna get some smart ass answers like:  Using the scroll bar lets you move them all.
What do you mean by move?

Ian C.

Commented:
Edited text of question
Commented:
Hi,

In delphi 2 i should do it like this (on top of my head, not tested)

procedure TStringGrid1.MoveMultRows(FromRow,ToRow,NRow:Intger);
var
i:Integer;
begin
//Moving rows Down
if ToRow>FromRow+Nrow then
For i:=1 to Nrow do MoveRow(FromRow,ToRow);
// Moving Rows Up
if ToRow<FromRow then
For i:=1 to Nrow do MoveRow(FromRow+NRow,ToRow);
//  if FromRow=FromRow then; do nothing
if (ToRow>FromRow) and (ToRow<=FromRow+NRow) then
MoveMultRows(FromRow+NRow+1,FromRow,ToRow-FRomRow);
// Recursive call, I did not run it my self so you might
// want to be carefull here.

end;

The Called MoveRow is a function of TCustomStringGrid (i think)
of which TString grid is derived.

GK

Not the solution you were looking for? Getting a personalized solution is easy.

##### Thanks for using Experts Exchange.

• View three pieces of content (articles, solutions, posts, and videos)
• Ask the experts questions (counted toward content limit)
• Customize your dashboard and profile