Recent

Author Topic: goColSelect  (Read 2615 times)

Abrax

  • New member
  • *
  • Posts: 7
goColSelect
« on: March 17, 2017, 02:51:13 pm »
I would like to implement the function of select an entire column clicked on the grid header. For example this way the user can select the reference column of a sorting. But the two selecting procedures (procedure SelectCell(ARow, ACol: Cardinal); procedure SetSelection(const ASelection: TsCellRangeArray); )  work strange.

I wrote a small program with two Buttons and a WorksheetGrid to test how selecting works. Click on the first button the sWorksheetGrid1.Worksheet.SelectCell(5,5) function try to select the F6 cell. If only 1 cell was previously selected it selects the proper cell. But if a region was previously  selected the function select a region to the given cell. And the area of the newly selected region depends on the starting and ending cells of the previous selection.

Click on the second button the procedure SetSelection(const ASelection: TsCellRangeArray); doesn't do anything.

Any idea how should I do it properly?


Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. begin
  3.   sWorksheetGrid1.Worksheet.SelectCell(5,5);
  4. end;  
  5.  
  6. procedure TForm1.Button2Click(Sender: TObject);
  7. var
  8.   Col,Row: integer;
  9.   aSelection: TsCellRangeArray;
  10.   sCellRange: TsCellRange;
  11. begin
  12.   setlength(aSelection,2);
  13.  
  14. //1. method to pass the first range corners
  15.   sCellRange.Col1:=1;
  16.   sCellRange.Col2:=3;
  17.   sCellRange.Row1:=1;
  18.   sCellRange.Row2:=3;
  19.   aSelection[0]:=sCellRange;
  20.  
  21. //2. method to pass the second range corners
  22.   aSelection[1].Row1:=4;
  23.   aSelection[1].Col1:=4;
  24.   aSelection[1].Col2:=6;
  25.   aSelection[1].Row2:=6;
  26.  
  27.   sWorksheetGrid1.Worksheet.SetSelection(aSelection);
  28. end;

 

TinyPortal © 2005-2018