I think this is more of an editor question than it is a PropertyGrid question, but here goes.
I've got some domain objects that I adapt into a PropertyGrid SelectedObject. The adapter isn't "much" more than adapted getters/setters wrapping the domain objects. With me so far? Good...
For some properties, I've built in INotifyBeforePropertyChanges, INotifyPropertyChanged, and INotifyAfterPropertyChanged interfaces, the .NET one is INotifyPropertyChanged, with the others doing the expected type operations.
In application, my domain objects have a Name, which I want to intercept and preclude duplicate names. Enter editor validations. It doesn't matter to me whether control over the editing is through the validations or we can utilize our property interfaces. Matters not.
I do have the BeforePropertyChanges event being handled at present. I look out to a list control and/or database for duplicate names and prompt the user when that's the case.
I'd like to do that through the PropertyGrid editor if possible: here's the code snippet setting that up.
However, the event doesn't seem to go at all. I think because my domain object event is getting in the way.
Edit: I've verified, the event is being hooked up, although it is a PropertyGridTextEditor and not BaseTextBoxEditor, which might have something to do with it. Event doesn't get dispatched.
Edit: Still doesn't go.
Can you confirm that the Validating event works?
I've got some domain objects that I adapt into a PropertyGrid SelectedObject. The adapter isn't "much" more than adapted getters/setters wrapping the domain objects. With me so far? Good...
For some properties, I've built in INotifyBeforePropertyChanges, INotifyPropertyChanged, and INotifyAfterPropertyChanged interfaces, the .NET one is INotifyPropertyChanged, with the others doing the expected type operations.
In application, my domain objects have a Name, which I want to intercept and preclude duplicate names. Enter editor validations. It doesn't matter to me whether control over the editing is through the validations or we can utilize our property interfaces. Matters not.
I do have the BeforePropertyChanges event being handled at present. I look out to a list control and/or database for duplicate names and prompt the user when that's the case.
I'd like to do that through the PropertyGrid editor if possible: here's the code snippet setting that up.
private
void
PropertyGrid_EditorInitialized(
object
sender, PropertyGridItemEditorInitializedEventArgs e)
{
Debug.Assert(e.Item
is
PropertyGridItem);
var __e_Item = e.Item
as
PropertyGridItem;
if
(__e_Item.Name.Equals(DataSourcePropertyGridNames.Name,
StringComparison.CurrentCultureIgnoreCase))
{
Debug.Assert(e.Editor
is
BaseTextBoxEditor);
var __e_Editor = e.Editor
as
BaseTextBoxEditor;
//TODO: Implement this and examine sender (I think).
__e_Editor.Validating += PropertyGrid_Name_Editor_Validating;
}
}
However, the event doesn't seem to go at all. I think because my domain object event is getting in the way.
Edit: I've verified, the event is being hooked up, although it is a PropertyGridTextEditor and not BaseTextBoxEditor, which might have something to do with it. Event doesn't get dispatched.
Edit: Still doesn't go.
Can you confirm that the Validating event works?