The watch property takes care of updating the textboxes with the calculation done in the respective functions. You do not have to assign any events or wait for it to change and do the extra work of validating. When you enter values inside any of the textboxes, whichever is changed, the Watch property takes care of updating both the textboxes. In both the functions, the conversion from kilometers to meters and from meters to kilometers is done. Here, we have created a watch object created with two functions kilometers and meters. We have initialized both textboxes the kilometers and meters to 0 in the data property. In the above example, we have created two textboxes, one with kilometers and another with meters. ![]() Let's enter 5 in the meter textbox and see the result in the output. Now, enter some value in the meter textbox and see the changes in the kilometers textbox. ![]() Let's enter 50 in kilometers textbox and see the result. If you enter some values in the kilometers textbox you can see the changes in the meters textbox and vice-versa. You can see that the output has the 0 entry in its textboxes. After the execution of the program, you will see the following output:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |