Skip to Content
avatar image
Former Member

How to dynamically change Text in a Button

I am trying to learn DS.  I want to know how I would change the text on a Button to the current date.  I searched and could not find any examples.  Can someone tell me how I would do this?

Thanks.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Nov 02, 2015 at 12:23 AM

    Look at this thread How to display "current date -1" means yesterda... | SCN

    application.getinfo method as mentioned in this thread - please try that and see if it meets your needs.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Sandy ,

      why do you need to two line of script just try this code in Application On Startup script:


      BUTTON_1.setText(APPLICATION.getInfo().dateNow);

      Once your Run the Application the button text will get change to current data .

      Hope this might help 😊

      Thanks

      Naveen

  • Nov 02, 2015 at 01:45 PM

    I'd not regard setting the text in the application startup script to be a best practice.  A year from now, you'll have the app open for tweaking and you'll have forgotten where you were setting the date.

    Set data minding on the button's text property and use a formatter function to set the text.  It's cleaner this way.

    Add comment
    10|10000 characters needed characters exceeded

    • I probably should have explained how to do it, I just did not have DS open for reference at the time.  I'm glad you got the hand of it.  Formatter functions allow you to greatly simplify the architecture of your apps.