Topic: Button Next

Hello everyone, how to display a name in a TexBox with a "Next" button.

Bonjour a tous, comment faire pour afficher un nom dans un TexBox avec un bouton "Suivant".

Re: Button Next

Hi Sabine,
Can you either upload an example of what you want to achieve or give more detail - specifically where the 'name' that you want to display in a text box is coming from (another field, a row in a tablegrid)?
Derek.

Re: Button Next

Hello Derek, here is the start of my project. I would like to navigate in the "Fish Names" TexBox with "Next" and "Previous" buttons, can you help me?

Bonjour Derek, voici le début de mon projet. Je voudrais naviguer dans le TexBox "Noms du poisson" avec des boutons "Suivant" et "Précédent", peut-tu m'aider?

Sabine

Post's attachments

Attachment icon Ma pêche.zip 338.16 kb, 131 downloads since 2022-05-06 

Re: Button Next

procedure Prises_OnShow (Sender: TObject; Action: string);
begin
  Prises.Edit4.Tag := -1;
end;

procedure Prises_bPrev_OnClick (Sender: TObject; var Cancel: boolean);
begin
  if ( Prises.Edit4.Tag > 0 ) then
  begin
    Prises.TableGrid1.SelectedRow := Prises.Edit4.Tag-1;
    Prises.Edit4.Tag := Prises.Edit4.Tag-1;
    Prises.bEdit.Click;
    Prises.TableGrid1.SelectedRow := Prises.Edit4.Tag;
  end;
  dooleanEnabledButton
end;

procedure Prises_TableGrid1_OnCellClick (Sender: TObject; ACol, ARow: Integer);
begin
  Prises.Edit4.Tag := Prises.TableGrid1.SelectedRow;
  dooleanEnabledButton;
end;

procedure Prises_bNext_OnClick (Sender: TObject; var Cancel: boolean);
begin
  if ( Prises.bNext.Tag < Prises.TableGrid1.RowCount ) then
  begin
    Prises.TableGrid1.SelectedRow := Prises.Edit4.Tag+1;
    Prises.Edit4.Tag := Prises.Edit4.Tag+1;
    Prises.bEdit.Click;
    Prises.TableGrid1.SelectedRow := Prises.Edit4.Tag;
  end;
  dooleanEnabledButton
end;

procedure dooleanEnabledButton;
begin
  if (Prises.Edit4.Tag+1 < Prises.TableGrid1.RowCount) then Prises.bNext.Enabled := True else Prises.bNext.Enabled := False;
  if (Prises.Edit4.Tag+1 > 1) then Prises.bPrev.Enabled := True else Prises.bPrev.Enabled := False;
end;
Post's attachments

Attachment icon MaPИche.zip 7.58 kb, 143 downloads since 2022-05-06 

Re: Button Next

Thanks to you Sibprogsistem, it works great.
Best wishes.

Sabine

Re: Button Next

Morning Sabine, Sibprogsistem,
Here's a slightly different way of doing it.
Derek.

Post's attachments

Attachment icon Ma pêche2.zip 339.45 kb, 165 downloads since 2022-05-06 

Re: Button Next

Thanks Derek, I will see to apply the best way to do it for my program.
Have a good day.

Merci Derek, je vais voir pour appliquer la meilleure façon de faire pour mon programme.
Bonne journée.

Sabine

Re: Button Next

How to add a "CheckBox" to the code.

Post's attachments

Attachment icon CheckBox.jpg 3.37 kb, 63 downloads since 2022-05-10 

Re: Button Next

Hi Sabine

Sorry, but we do not understand what you are talking about and most importantly what you are thinking. )))
What do you want to see, what code are you talking about?

10 (edited by sdpc62 2022-05-10 14:29:39)

Re: Button Next

I talk about the rest of the code on this post "My fishing", I would like to include its ChekBox in my program.

Post's attachments

Attachment icon Ma pêche2.zip 339.73 kb, 131 downloads since 2022-05-10 

11 (edited by sibprogsistem 2022-05-10 15:15:32)

Re: Button Next

if (prises.tablegrid1.SelectedRow) then
   SQLExecute('UPDATE Prises SET "'+TdbCheckBox(Sender).dbField+'"="'+TdbCheckBox(Sender).sqlValue+'"WHERE id='+prises.tablegrid1.sqlvalue);



  for i := 0 to Prises.ComponentCount-1 do
    if (TdbCheckBox(Prises.Components[i]) is TdbCheckBox) then
      TdbCheckBox(Prises.Components[i]).Checked := StrToBool(SQLExecute('SELECT IFNULL("'+TdbCheckBox(Prises.Components[i]).dbField+'",0) FROM Prises WHERE id='+prises.tablegrid1.sqlvalue));

Parent по чему-то не сработал сделал через is

Post's attachments

Attachment icon MaPИche.zip 8.51 kb, 151 downloads since 2022-05-10 

Re: Button Next

Thank you Sibprogsistem, I completed the code and it works great.
thank you