Hi,
I implemented a validation system for my propertyGrid's model and i want to put the focus on the current propertyItem having errors for the user correct it.
Here my function :
Thank you for your help.
I implemented a validation system for my propertyGrid's model and i want to put the focus on the current propertyItem having errors for the user correct it.
Here my function :
private string _message = "";
private bool ValidateProperties(PropertyItemCollection pProperties)
{
bool isExpandedState = false;
foreach (var property in pProperties)
{
if (Validation.GetHasError(property))
{
foreach (var error in Validation.GetErrors(property))
{
_message += error.ErrorContent.ToString() + "\n";
}
//_message = Validation.GetErrors(prop)[0].ErrorContent.ToString();
property.IsSelected = true;
property.Focusable = true;
property.Focus();
return false;
}
else if (property.IsExpandable)
{
isExpandedState = property.IsExpanded;
property.IsExpanded = true;
if (!ValidateProperties(property.Properties))
return false;
else
property.IsExpanded = isExpandedState;
}
}
return true;
}
property.Focusable = true and property.Focus() doesn't work.Thank you for your help.