We are experiencing a problem when using rowenabled in combination with nodes. Is there a way to fix this?
Example code:
procedure TForm1.FormCreate(Sender: TObject);
begin
Grid.DisabledFontColor := clblack;
Grid.Navigation.AdvanceOnEnter := true;
Grid.Navigation.AdvanceDirection := TAdvanceDirection.adTopBottom;
Grid.Navigation.AdvanceSkipReadOnlyCells := true;
Grid.Navigation.SkipDisabledRows := true;
Grid.RowCount := 15;
Grid.Cells[1, 1] := 'level 1';
Grid.Cells[1, 2] := 'list 1.1';
Grid.Cells[1, 3] := 'list 1.2';
Grid.Cells[1, 4] := 'level 2';
Grid.Cells[1, 5] := 'list 2';
Grid.Cells[1, 6] := 'level 3a';
Grid.Cells[1, 7] := 'list 3a.1';
Grid.Cells[1, 8] := 'list 3a.2';
Grid.Cells[1, 9] := 'list 3a.3';
Grid.Cells[1, 10] := 'level 3b';
Grid.Cells[1, 11] := 'list 3b.1';
Grid.Cells[1, 12] := 'list 3b.2';
Grid.Cells[1, 13] := 'list 3b.3';
Grid.AddNode(10, 4); // node level 3b
Grid.AddNode(6, 4); // node level 3a
Grid.AddNode(4, 10); // node level 2
Grid.AddNode(1, 13); // node level 1
// disable the node-rows
Grid.RowEnabled[1] := false;
Grid.RowEnabled[4] := false;
Grid.RowEnabled[6] := false;
Grid.RowEnabled[10] := false;
// disable some data rows
Grid.RowEnabled[8] := false;
Grid.RowEnabled[12] := false;
Grid.Options := Grid.Options + [goEditing];
end;
procedure TForm1.GridGetCellColor(Sender: TObject; ARow, ACol: Integer;
AState: TGridDrawState; ABrush: TBrush; AFont: TFont);
begin
if (Sender as TAdvStringGrid).RowEnabled[ARow] then
AFont.Color := clgreen
else
AFont.Color := clred;
if (Sender as TAdvStringGrid).IsNode(ARow) then
ABrush.Color := clYellow;
end;
After loading form, looks like expected:
After closing a node (level 3a):
Reopening this node: