Of Datagridviews, databinding, and non validating cell values.

Posted by Yanko Hernández Alvarez on Stack Overflow See other posts from Stack Overflow or by Yanko Hernández Alvarez
Published on 2010-05-11T19:02:47Z Indexed on 2010/05/11 19:14 UTC
Read the original article Hit count: 292

Filed under:
|
|
|

Lets simplify. Lets say I have this class:

class T {
   public string Name { get; set; }
   public int Age { get; set; }
   public int height{ get; set; }
   ...
}

and I have a DataGridView's DataSource bound to a BindingList <T>, with N columns, each one bound to each property.

I need to:

  • Allow the user to enter non validating ages, heights, etc (for instance "aaa")
  • Color the cells with non validating values (red background)
  • Retain the non validating values displayed until the form is closed (I don't want to lose the values entered until the form is closed, so the user has the option to correct the bad cells anytime he wants BEFORE closing the form)
  • Keep the last correct values entered for each cell with non validating values entered.
  • When the form is closed, ditch the non validating values and keep the last correct values entered.

Is there any easy way to do this?

© Stack Overflow or respective owner

Related posts about c#

Related posts about winforms