prevent canceling control events
This commit is contained in:
@@ -44,6 +44,8 @@ public class RadValidationProviderEx : Component, ISupportInitialize, IExtenderP
|
|||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
|
|
||||||
|
public bool AllowCancelControlEvents { get; set; } = true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Occurs before a RadControl is being validated.
|
/// Occurs before a RadControl is being validated.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -370,9 +372,8 @@ public class RadValidationProviderEx : Component, ISupportInitialize, IExtenderP
|
|||||||
var node = DataUtils.Parse(ruleToEvaluete.Expression, ruleToEvaluete.CaseSensitive);
|
var node = DataUtils.Parse(ruleToEvaluete.Expression, ruleToEvaluete.CaseSensitive);
|
||||||
var result = node.Eval(null, context);
|
var result = node.Eval(null, context);
|
||||||
|
|
||||||
if (result is bool)
|
if (result is bool boolResult)
|
||||||
{
|
{
|
||||||
var boolResult = (bool)result;
|
|
||||||
var validationEventArgs = FireValidationEvent(!boolResult, (RadControl)sender, ruleToEvaluete);
|
var validationEventArgs = FireValidationEvent(!boolResult, (RadControl)sender, ruleToEvaluete);
|
||||||
if (validationEventArgs.DisplayIconAndToolTip)
|
if (validationEventArgs.DisplayIconAndToolTip)
|
||||||
boolResult = AddOrRemoveImage(validationEventArgs, (RadControl)sender, ruleToEvaluete);
|
boolResult = AddOrRemoveImage(validationEventArgs, (RadControl)sender, ruleToEvaluete);
|
||||||
@@ -381,8 +382,7 @@ public class RadValidationProviderEx : Component, ISupportInitialize, IExtenderP
|
|||||||
boolResult = validationEventArgs.IsValid;
|
boolResult = validationEventArgs.IsValid;
|
||||||
}
|
}
|
||||||
|
|
||||||
var cancelEventArgs = e as CancelEventArgs;
|
if (AllowCancelControlEvents && e is CancelEventArgs cancelEventArgs)
|
||||||
if (cancelEventArgs != null)
|
|
||||||
cancelEventArgs.Cancel = !boolResult;
|
cancelEventArgs.Cancel = !boolResult;
|
||||||
|
|
||||||
if (!boolResult)
|
if (!boolResult)
|
||||||
|
|||||||
@@ -20,7 +20,10 @@ public partial class RadFlyoutBase : UserControl
|
|||||||
public static RadSvgImage? ConfirmSvg { get; set; } = null;
|
public static RadSvgImage? ConfirmSvg { get; set; } = null;
|
||||||
|
|
||||||
[Browsable(false)]
|
[Browsable(false)]
|
||||||
public RadValidationProviderEx ValidationProvider { get; } = new();
|
public RadValidationProviderEx ValidationProvider { get; } = new()
|
||||||
|
{
|
||||||
|
AllowCancelControlEvents = false,
|
||||||
|
};
|
||||||
|
|
||||||
[ReadOnly(true)]
|
[ReadOnly(true)]
|
||||||
public DialogResult Result { get; protected set; }
|
public DialogResult Result { get; protected set; }
|
||||||
|
|||||||
Reference in New Issue
Block a user