1 (edited by reteinformatica 2023-04-01 19:46:32)

Topic: Name of a control in a PageControl

Hello everyone and thank you for reading my request: I inserted a PageControl in a form and inside it I inserted a button.

Name form: Start
PageControl Name: PageControl1
TabSheet Name: TabSheet7
Button name: bInseriscidipendente

I wrote an instruction:

Start.PageControl1.TabSheet7.bInseriscidipendente.click;

When the program starts, it writes me: Undeclared identifier: 'TabSheet7'

Thank you all and best regards.

Re: Name of a control in a PageControl

Hi Fabio,
Each object on a form must have its own unique name (for example, Button1, Button2, Button3).
Because the name is unique, you do not need to qualify it by specifying the relevant page control or tabsheet.
So in your example, the instruction is simply

Start.bInseriscidipendente.click

Derek.

3 (edited by reteinformatica 2023-04-01 20:26:11)

Re: Name of a control in a PageControl

Hi derek, as always you are decisive and I learned something new.
If you don't mind I would like to ask you one more thing. As in the other project where he helped me I wanted to insert a button to save the record and continue to insert other records without closing the window or at least that it reopens as soon as the record is saved.
I wrote these instructions following a little bit of the instructions you had written for me:

var nuovo : string;

procedure frmDipendenti_bSalvainseriscidipendente_OnAfterClick (Sender: TObject);
begin
  if nuovo = 'new' then
    begin
      Start.bInseriscidipendente.click;
      frmDipendenti.edNomedipendente.setfocus;
    end else frmDipendenti.close;
end;

The reccord is saved but the window also closes. I unchecked the configuration of the "Close after saving..." button.

Re: Name of a control in a PageControl

Hi,
I would guess that frmDipendenti is closing on save (but not immediately reopening again) because you haven't set the value of your global variable (nuovo) to 'new'.
Derek.

Re: Name of a control in a PageControl

It was just like that, I was able to achieve the goal. Always so many thanks

Re: Name of a control in a PageControl

Hello reteinformatica, derek!
I can only add that there are two concepts: controls and components. Controls are located on parent controls (this can be a form, panel, etc.), and components belong to the form, regardless of which control they are located on. The script works with components, that is, to access the component, the form name is specified, and then the component name.

Визуальное программирование: блог и телеграм-канал.