Dynamic captionso on buttons

Mauddib
Mauddib Member Posts: 269
I have just been reading all the search results I can find on this and no one seems to have done it.

Can you dynamically set the caption on a button on a form at runtime. Opopen or anything. I know you can do this with the captionclass property on the form for fields and so on, but it doesnt appear to work with buttons.

Anyone managed this with a DLL or OCX, or by changing captionclass in Codeunit 1 or anything?

Answers

  • diptish.naskar
    diptish.naskar Member Posts: 360
    I don't think you can change the caption of a Button at runtime in Navision based on some criteria, the main reason being the Property 'Caption' is not available at rutime for buttons.

    However you can try this.

    Create two buttons and provide different captions on them, now make them visible / non visible directly on the runtime based on the criteria..Place the two buttons ovelapping so during the runtime the user is able to see only one single button.... :wink:

    Oh...One more thing if you do this...do please use the documentation trigger to document the same..as this may create some confusion in the form buttons..
    Diptish Naskar
    For any queries you can also visit my blog site: http://msnavarena.blogspot.com/
  • kine
    kine Member Posts: 12,562
    There is one way with layered EditBox and Transparent button. I described it one post but which one it was... :whistle:

    Main idea was to have one button without caption which is doing the :shape: of the button, on it is edit box without borders and transparent with the dynamic caption, and on it third button, which fires the OnPush trigger and is doing the job (once again transparent and without borders etc...).
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • ta5
    ta5 Member Posts: 1,164
    Another idea: Not at runtime, but dynamic. Have a look to the captionclass thing.

    Maybe this helps
    Thomas
  • Mauddib
    Mauddib Member Posts: 269
    Kine you either almost have it or you have it and i misunderstood your description!

    An old colleuge just told me how to do it and its really easy. Its done the same way as the COMMENTS button on item card, sales order, purchase order etc etc.

    Basically create a button with showcaption set to NO and Back Transparent set to YES.

    Now create a textfield with source being a variable of type Text and place it over the button with same size as button.

    Now you can change the value of the text variable and the 'caption' on the button appears to change. Wonderfully simple.
  • Luc_VanDyck
    Luc_VanDyck Member, Moderator, Administrator Posts: 3,633
    When you resizes/maximizes the form, does the caption alligns with the button?
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • Mauddib
    Mauddib Member Posts: 269
    Yes if all glue and size and position settings are the same.
  • kine
    kine Member Posts: 12,562
    Mauddib wrote:
    Kine you either almost have it or you have it and i misunderstood your description!

    :-) The described solution with two buttons and one edit box is the solution which is visually same as common button. Your solution with just one button and editbox have some visual differences (mainly under XP and Vista). It is why I am using two buttons... ;-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.