Good afternoon Bruno,
sorry for this email .... but there's a new problem ....
Using your last test program modify the oncreate event as follow, where the red color is only to see the 'busy' state of the row (SG1 is TadvStringGrid).
procedure TForm1.FormCreate(Sender: TObject);
var I : Integer;
begin
SG1.RowCount := 10000;
SG1.ColCount := 20;
for I:=1 to SG1.ColCount - 1 do
SG1.GridCells[I,0]:='Colonna ' + inttostr(I);
SG1.LinearFill(False);
SG1.Navigation.KeepHorizScroll := true;
SG1.Options := SG1.Options + [goRowSelect];
SG1.LeftCol := 10;
SG1.RowColor[1]:=clRed; // NEW
SG1.RowColor[3]:=clRed; // NEW
SG1.RowColor[5]:=clRed; // NEW
SG1.AutoSizeColumns(True);
end;
and
procedure TForm1.SG1CanClickCell(Sender: TObject; ARow, ACol: Integer;
var Allow: Boolean);
begin
if SG1.Colors[1,Arow]=clRed then
begin
Allow:=False;
end;
end;
Now .... the first row color is red and selected, try to click with left mouse button and (while is pressed) move up, the grid is redrawed but with a left offset.
Last question, there is an event that is called before the cell or row is selected ?
In this case, if the selected row has red color .. can't be selected.
Thank's for your attention.
Regards
Daniele
- We fixed this problem2) The grid.OnSelectCell() is triggered before the new selection is effective.
Good morning Bruno,
1) Thank's
2) For any mystrerious reason i did not see it !!!!
This works as expetted but, only in this case, if the selection is made with the mouse (left button down and the selection is made moving the mose up/down) the row is select even if the CanSelect, in OnSelectCell event, is setted to false.
If the row color is red, the selection is not allowed; with oncanclickcell and onrowchanging i can control the work and avaoid the selection or row changing with mouse/keyboard. But with goRangeselect setted (option) and DisjunctRowSelect:=True (MouseAction) the selection is allowed.
For sure, there's something i miss ..
Thanks' for all,
Have a nice week
Daniele