Good afternoon,
j'm sorry for using old 3.7 version of TFlexCel but and j've a problem when j need to selcts a range of rows and columns.
There's an example that show how it's possible select a range of coluns & rows with a mouse in flexcelgrid ??
j'm not able to find a way to change the 1,1,1,1 with 1,1,x,y in the follow procedure (if it's a correct way !!!)
procedure TFRGEXL.Btn4Click(Sender: TObject);
var
xls: TXlsFile;
RG : TXlsCellRangeArray;
begin
RG:=TXlsCellRangeArray.Create(TXlsCellRange.Create(1, 1, 1, 1));
xls := (FcI1.GetWorkbook as TXlsxFile).GetTWorkbook;
xls.SelectCells(RG);
end
Thank's in advance
Good week end
Daniele
Hi,
FlexCelGrid is a descendent from VCL's TCustomGrid and it inherits its properties and also limitations.
To be able to select cells with the mouse, the grid needs to be readonly. This is a limitation in TCustomGrid, there is not much we can do about it. If you open the XlsViewer demo and press the "ReadOnly" button (third button from the right), you will see how you can select ranges.
This problem is very well known in delphi TGrid, for example: http://stackoverflow.com/questions/2861020/tstringgrid-with-both-editing-and-range-selection?rq=1
To do it with code, again, you need to remember this is a standard TGrid, so you need to use the methods there.
For example:
var
myRect: TGridRect;
begin
myRect.Left := 3;
myRect.Top := 1;
myRect.Right := 5;
myRect.Bottom := 4;
FlexCelGrid1.Selection := myRect;
end;
As said, this is all standard TGrid code, you can find a lot of information in internet about it.
For the new TFlexCelSpreadsheet component I would like to do, it will likely not descend from TGrid, so it won't have those kind of limitations. But in FlexCelGrid, it is a TGrid, and all the mehtods that apply to a TGrid apply to it.