tags
tags

Reputation: 4060

C# WFA. send sum of richTextBoxes towards another richTextBox

i have a series of richTextBoxes, i want to make the sum of their double.Parsed value and send this total value in another richTextbox.

on my screen i would have a column of richTextBox containing nicely formatted prices, and a "total" richTextBox at the bottom

one possibility would have been to raise a TextChanged event. but, it can handle ONLY ONE change at a time.

what i need is to make the calculation if ANY of the values in other richTextBoxes ( = if any price is entered) has changed.

but, i don't know how to do that.

Upvotes: 0

Views: 305

Answers (2)

tags
tags

Reputation: 4060

i finally put every single calculation into an independent class. each class test the nature of the value using the TryParse method. if it succeeds, the method returns the doubled formatted value, otherwise it returns 0. the "sum up" class simply calls each class described above. and the "sum up" class is tied to a TextChanged event.

Upvotes: 0

Øyvind Bråthen
Øyvind Bråthen

Reputation: 60744

Set all the textboxes to call the same method for TextChanged.

Then in this method calculate the total of all textboxes, regardless of which one was changed, and put the total inside the Sum textbox.

If should be pretty straight forward.

If this does not solve your problem, please give a better description of your problem.

Upvotes: 1

Related Questions