title: Best way to handle invalid input data in WinForms?
body: <p>I've put together a form in which a user can dynamically generate a customer order with one or more order positions. For each position, there are several attributes like amount, product name, price, discount etc.</p>
  <p>My main problem is: What is the best way to deal with invalid values for the input fields? For example if a user types &quot;X&quot; into the amount field instead of 1, 2 or whatever.
  The basic idea was to let the user enter everything they want - but the order can only be saved once every input field contains valid data. If not, all invalid fields will be highlighted so the user knows what he did wrong.</p>
  <p>So far, this seems to work just fine but my idea was to also have a Customer_Order object which would be updated everytime the user changes the value of an input field.
  Obviously I could not do that if I want to allow the user to enter Strings like &quot;X&quot; into Integer or Decimal fields... so it seems to me that I have 2 options:</p>
  <p>A: Either restrict the input fields and programatically turn invalid values into zeros (For example: User enters &quot;abc&quot; into price field -&gt; String will be converted to 0,00)
  OR B: keep my original plan with not so strict input regulations and NOT have a Customer_Order object that is always kept up to date. I would instead create the object from scratch and fill it with all the data from the input fields when the user finishes the order.</p>
  <p>My problem with A is that I would like to keep the input fields as non-strict as possible. If a user types in something invalid, they should SEE what they typed in instead of the program changing the value. And my problem with B is that having an always up-to-date object of the customer order makes it easier to calulate prices on the fly. If I don't have that object, I would have to read out and parse all the necessary input fields every time I want to calculate something.</p>
  <p>I'm not that experienced with GUIs so I really don't know if I'm missing something here... what would be the most elegant way to handle this? Is it generally a bad idea to have an always up-to-date object in the background at all times?</p>