EtheaDev / StyledComponents

Components similar to Delphi VCL Buttons, Toolbar, DbNavigator, BindNavigator, ButtonGroup and CategoryButtons with Custom Graphic Styles, and an advanced, full-customizable TaskDialog, also with animations!
Apache License 2.0
152 stars 34 forks source link

How can I Enable or disable Buttons runtime #52

Closed vafadar1977 closed 6 days ago

vafadar1977 commented 1 week ago

How can I Enable or disable Buttons runtime using OnEnableNavBtn?

This code is not working. StyledDBNavigator1.Buttons[nbPost].EnabledNavBtn(False);

please write a sample line for this option.

carloBarazzetta commented 1 week ago

As I already exaplained in last issue, look the example in the StyledComponentsDemo - form StyledDbNavigatorForm: EnableNavBtn is an event handler that you must link to your StyleDbNavigator. The event passes AEnabled param that is the default value for a specific ABtn (for example when the dataset is in EOF for ABtn.Index.nbLast button the value of AEnabled is false and the value of AEnabled for ABtn.Index.nbFirst is True. For example, If you want to disable the Delete button based to another function "UserCanDelete":

  if (ABtn.Index = TNavigateBtn.nbDelete) then
    AEnabled := UserCanDelete;

where UserCanDelete is your specific rule for enabling deletion of record.

vafadar1977 commented 1 week ago

Dear Carlo,

Thanks a lot for adding new option to this component.

On Sun, Oct 13, 2024 at 11:12 AM Carlo Barazzetta @.***> wrote:

As I already exaplained in last issue, look the example in the StyledComponentsDemo - form StyledDbNavigatorForm: EnableNavBtn is an event handler that you must link to your StyleDbNavigator. The event passes AEnabled param that is the default value for a specific ABtn (for example when the dataset is in EOF for ABtn.Index.nbLast button the value of AEnabled is false and the value of AEnabled for ABtn.Index.nbFirst is True. For example, If you want to disable the Delete button based to another function "UserCanDelete":

if (ABtn.Index = TNavigateBtn.nbDelete) then AEnabled := UserCanDelete;

where UserCanDelete is your specific rule for enabling deletion of record.

— Reply to this email directly, view it on GitHub https://github.com/EtheaDev/StyledComponents/issues/52#issuecomment-2408865004, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFOYHJHIH7AT2QXTRVXQWKTZ3IP6VAVCNFSM6AAAAABP2VRCGKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMBYHA3DKMBQGQ . You are receiving this because you authored the thread.Message ID: @.***>

--

Hossein Vafadar