Here some code to move a (multiple) selection up or downwards. When the first selected row reaches the top it starts condensing free space in a multiple selection until there is none left. This way the order of rows will not change when reaching the top or bottom.
Upwards:
CODE
procedure TForm1.ToolButton27Click(Sender: TObject);
var
i, j : Integer;
begin
//determine if we can move or condense any further upwards
for i := 0 to Pred(GridView6.SelectedCount) do
if not (GridView6.Selected[i]) then
begin
for j := i to Pred(GridView6.RowCount) do
if (GridView6.Selected[j]) then
GridView6.MoveRow(j, j - 1);
Break;
end;
end;
var
i, j : Integer;
begin
//determine if we can move or condense any further upwards
for i := 0 to Pred(GridView6.SelectedCount) do
if not (GridView6.Selected[i]) then
begin
for j := i to Pred(GridView6.RowCount) do
if (GridView6.Selected[j]) then
GridView6.MoveRow(j, j - 1);
Break;
end;
end;
Downwards:
CODE
procedure TForm1.ToolButton28Click(Sender: TObject);
var
i, j : Integer;
begin
//determine if we can move or condense any further downwards
for i := Pred(GridView6.RowCount) downto (GridView6.RowCount - gridView6.SelectedCount) do
if not (GridView6.Selected[i]) then
begin
for j := i downto 0 do
if (GridView6.Selected[j]) then
GridView6.MoveRow(j, j + 1);
Break;
end;
end;
var
i, j : Integer;
begin
//determine if we can move or condense any further downwards
for i := Pred(GridView6.RowCount) downto (GridView6.RowCount - gridView6.SelectedCount) do
if not (GridView6.Selected[i]) then
begin
for j := i downto 0 do
if (GridView6.Selected[j]) then
GridView6.MoveRow(j, j + 1);
Break;
end;
end;
Due to a 'bug' the indicator column isn't changed.
Have fun coding.











