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?
procedure TForm1.Button1Click(Sender: TObject);
begin
sWorksheetGrid1.Worksheet.SelectCell(5,5);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
Col,Row: integer;
aSelection: TsCellRangeArray;
sCellRange: TsCellRange;
begin
setlength(aSelection,2);
//1. method to pass the first range corners
sCellRange.Col1:=1;
sCellRange.Col2:=3;
sCellRange.Row1:=1;
sCellRange.Row2:=3;
aSelection[0]:=sCellRange;
//2. method to pass the second range corners
aSelection[1].Row1:=4;
aSelection[1].Col1:=4;
aSelection[1].Col2:=6;
aSelection[1].Row2:=6;
sWorksheetGrid1.Worksheet.SetSelection(aSelection);
end;