Here my code to "access" my FRAMES using OnCLICK on TreeView selection:
use like you want!!! if need use ONChange the logic can be the same or different!
procedure TfrmFormMainExec.tvMyFramesInfoClick(Sender: TObject); var lMyTreeNodeSelected: TTreeNode; lMyFrameSelected: TFrame; lMyComponentInTheFrame: TComponent; //... begin // lMyTreeNodeSelected := (Sender as TTreeView).Selected; // if (lMyTreeNodeSelected <> nil) then begin if (lMyTreeNodeSelected.Data <> nil) and (TObject(lMyTreeNodeSelected.Data).InheritsFrom(TFrame)) then begin lMyFrameSelected := TFrame(TObject(lMyTreeNodeSelected.Data)); // find by "Class" lMyComponentInTheFrame := fncFindMyFirstComponentType(lMyFrameSelected, TMaskEdit); // grdpnlOnTheForm.FindComponent('Edit1') // if (lMyComponentInTheFrame <> nil) then begin TEdit(lMyComponentInTheFrame).SetFocus; TEdit(lMyComponentInTheFrame).Color := clGreen; // if (lLastEditFocused <> nil) and (lLastEditFocused <> lMyComponentInTheFrame) then lLastEditFocused.Color := clWindow; // lLastEditFocused := TEdit(lMyComponentInTheFrame); end; // // ShowMessage(Format('%s, is a [Frame]'#13#10'Im on [%s]', [lMyTreeNodeSelected.Text, lMyFrameSelected.Name])); end else begin if (lLastEditFocused <> nil) then lLastEditFocused.SetFocus; // ShowMessage(lMyTreeNodeSelected.Text + ', This Object is [NIL]'); end; end; end;
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3