Recent

Author Topic: StringGrid: How to avoid moving rows over/under some rows?  (Read 680 times)

Jvan

  • Full Member
  • ***
  • Posts: 120
Re: StringGrid: How to avoid moving rows over/under some rows?
« Reply #15 on: August 18, 2020, 11:21:23 pm »
Finally, I did it.

Code: Pascal  [Select][+][-]
  1. procedure TForm1.StringGrid1ColRowMoved(Sender: TObject; IsColumn: Boolean;
  2.   sIndex, tIndex: Integer);
  3. begin
  4.   if not(IsColumn) and (StringGrid1.Tag = 0) then begin  //Only rows
  5.     if (sIndex <= 5) and (tIndex > 5) then begin
  6.       //AVOID MOVING
  7.       StringGrid1.Tag := 1;
  8.       ShowMessage('Error: La fila que desea mover no corresponde al grupo de su nuevo lugar.');
  9.       StringGrid1.MoveColRow(false, tIndex, sIndex);
  10.       StringGrid1.Tag := 0;
  11.     end else if (sIndex > 5) and (tIndex <= 5) then begin
  12.       //AVOID MOVING
  13.       StringGrid1.Tag := 1;
  14.       ShowMessage('Error: La fila que desea mover no corresponde al grupo de su nuevo lugar.');
  15.       StringGrid1.MoveColRow(false, tIndex, sIndex);
  16.       StringGrid1.Tag := 0;
  17.     end;
  18.   end;
  19. end;
  20.  
  21.  

 

TinyPortal © 2005-2018