Alright, this is kill'n me.

Topics: Developer Forum
Jan 11, 2007 at 9:53 AM
I run your SampleApp.
I've gotta breakpoint on the "set" FirstName of Person.
I hit a key in the firstNameTextBox.
BRRRRRRRREAK!
How are you getting TextChanged relayed to Person?!
Jan 11, 2007 at 12:25 PM
It should be breaking.
First guess is- Have you put the breakpoint on the correct Person?
Sorry about the confusion but there are a number of ‘PersonXXX’ classes. The one you should have placed the breakpoint in is G:\Code\Validation\SampleBusinessLayer\Person.cs on line 59. All the others are used for the creation of help ducumentation.

Other than that have you made any other changes? Does the validation for firstname still show on the form when you run it?
Jan 12, 2007 at 12:18 AM
Sorry for the confusing question. What I meant was. I've lost 3 keyboards in one week trying to reproduce the event. Simply put, it's freak'n awesome your framework does this. Is there something special I'm missing? I only get the event fired after losing focus.
Jan 12, 2007 at 12:21 AM
Let me add to this. I'm not too much of an attributes fan. But, I've been learning a great deal from your framework. I just can't figure out how your "Person" catches the TextChanged event of a TextBox. You framework works perfect, I'm just trying to disect it. :)
Jan 12, 2007 at 3:21 AM
It fires back to the set because the Text property of the textbox is data bound to the FirstName property of person. The trick is that you need to set the “data source update mode” to OnPropertyChanged. This means that when the property “Text” changes the databinding fires back to Person.

To do this on the designer expand the DataBindings property and click on the Advanced ellipsis. You can then choose your data source and the update mode.

The code, that will be created in you “.Designer.cs” file, is


this.personBindingSource.DataSource = typeof(SampleBusinessLayer.Person);

this.firstNameTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.personBindingSource, "FirstName", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));


As fo not liking attribute… You can also add validation rules programtically. See TypeCache and MethodCache. If you are interested I can fasttrack some detailed examples on my next checkin. I am also working on being able to add validation rules via a configuration file.
Jan 12, 2007 at 4:41 PM
> you need to set the “data source update mode” to
> OnPropertyChanged.

BINGO! My current keyboard says thank you very much. Databindings -> Advanced. No wonder I never saw it. "Advanced" for me means, "Do not touch!" :)

> If you are interested I can fasttrack some detailed examples on my
> next checkin.

If it's not too much trouble, bring'em on.

I want to thank you for your time and your framework.

Kind regards,
Marc
Jan 14, 2007 at 12:52 PM
Marc
On the latest check-in I have added a sample that shows how to programmatically add validation rules to a property using TypeCache. See “\Validation\SamplesLibrary\Reflection\TypeCacheSample.cs”
I will add one for MethodCache shortly.
Let me know if you have any problems.

BTW. Any feature requests, suggestions or issues??

Jan 14, 2007 at 7:37 PM
Excellent! I'm downloading it right now. No requests or issues at the moment. Give me a moment to review your examples. Thanks again!
Jan 14, 2007 at 8:55 PM
Wonderful example! I'm just starting to dig in, so give me a few. I did have one question. I truly dig the "levels" of abstraction with the base classes: NotifyValidatableBase, etc. If you were to throw IEditableObject in the mix, where do you see its place? Ok, back to digging.
Jan 18, 2007 at 10:44 AM
Mark

I have done a little research on IEditableObject and I cannot see any value I could add in a base class by including it in the base business classes of the framework. It is too dependent on how you implement your classes to write generic code for. I have seen several ways of implementing it and each has advantages and disadvantages. So I guess that means you have to decide which interfaces your business classes would need and then pick your base class (DataErrorInfoValidatableBase, ValidatableBase, or NotifyValidatableBase). From that you can then create a base class for all your business objects to inherit from.
I would be interested in seeing what you come up with. So it would be great if you could post your code.
Good luck and sorry i could not be more help.
Feb 4, 2007 at 7:04 PM
It was a breeze. Prior to finding your framework, I had one class named BusinessObject. It had EVERYTHING in it. I think if I had added one more #region, VS would've blown a fuse. Anyway, I simply incorporated your data, val and notify base classes and added an EditableBusinessObject abstract class that inherits from your NotifyValidatableBase and implements IEditableObject. I then used your excellent CustomClassUsingPropertyValidationManager example and DING..we have a winner.

The reason I posted the question was, I was looking at your ErrorProviderNotifier. My original question was kinda in left field. I guess I thought you were gonna somehow hook into BeginEdit/EndEdit.

Your excellent work has taught me alot. Keep up the great work!