Options

How to Change font attribute dinamicaly (onPush button)

jemmyjemmy Member Posts: 247
Folks,

I need a best answer for following problems:

1) New Form
2) Declare Global variable named MyIntVar, data type = integer
3) In Init form assign the variable with value, e.g: 123
4) Add a new textbox in the form, and put MyIntVar as its sourceExpr
5) Add a new push button, and in its onPush trigger, I want to change the font attribute from normal to BOLD.
Try to use command=
CurrForm.TextBoxName.UPDATEFONTBOLD (TRUE);

But it failed and gave an error
Dynamic Property 'Font' cannot be changed in this context.
You tried to change 'Font' to on the Textbox named 'TextBoxName'.


Anyone knows how to make it works?

Thanks in advance as always,

Jemmy

Comments

  • Options
    janpieterjanpieter Member Posts: 298
    try using the OnFormat trigger of the textbox.

    There you can update the font of the textbox.

    I hope the case that you wrote down is just an example. I don't think you can change the textbox by clicking a button. Or you should make 2 textboxes with different fonts and change the visible property of this textboxes when you click the button.
    In a world without Borders or Fences, who needs Windows and Gates?
  • Options
    jemmyjemmy Member Posts: 247
    Hehe.. Thanks a lot Jan, but I don't think if adding a new control and make it visible and invisible is a best idea.
    What I did is:

    onFormat trigger
    CurrForm.TextBoxName.UPDATEFONTBOLD (BooleanVar);

    onPush trigger
    BooleanVar := TRUE;

    But I really don't know if there is a system function to take the format directly...
    and the error message really confused me.

    Any idea?


    Jemmy
  • Options
    janpieterjanpieter Member Posts: 298
    Nope this is the way you have to do that.

    I would question 1 thing with what you did and that is: is the onformat trigger of the textbox executed in every situation when you click the button?

    Interesting ... If the trigger is not executed then the font isnt changed ...
    In a world without Borders or Fences, who needs Windows and Gates?
  • Options
    jemmyjemmy Member Posts: 247
    Nice question, yes.. it's executed each time the user click the button.
    If user didn't push the button, the font is still normal, then once he pushes it'll become bold.


    I think all functions in C/Side are communicating each other using its parameter.. and we sometimes can't access it directly.
    Let me know if my opinion goes to wrong direction...


    Cheers,

    Jemmy
  • Options
    ShenpenShenpen Member Posts: 386
    Please don't forget the CurrForm.UPDATE(TRUE); in the OnPush to make it sure it will always happen.

    Also, in a real application you could do this:

    f.e. Unit Price on Sales Order is bold when zero:

    - code to OnFormat (bold and colors together rule :) )
    - Currform.UPDATE(TRUE); to OnAfterValidate to the Unit Price field to reload the record when you change the value, so the font changes instantly when you leave the field and not just later when you leave the record

    Do It Yourself is they key. Standard code might work - your code surely works.
  • Options
    ShenpenShenpen Member Posts: 386
    Did it work?

    Do It Yourself is they key. Standard code might work - your code surely works.
  • Options
    jemmyjemmy Member Posts: 247
    Hello Shenpen,

    Yes, it works....
    By the way, Do you have any idea?

    Cheers,

    Jemmy
Sign In or Register to comment.