I’m trying to have a logical field bound to a checkbox control be disabled based on the value of a numeric field. If the numeric value is >= 10 then the checkbox control should be read only or disabled (or invisible for that matter). I haven’t been able to disable the checkbox. Any thoughts? Both fields are in the OrderHed_UD table. The read-only version of the rule is below. Thanks.
private void CreateRowRule_PreAuthorizationExists()
{
// Description: PreAuthorization Exists
// **** begin autogenerated code ****
ControlSettings controlSettings1EpiReadOnly = new ControlSettings();
controlSettings1EpiReadOnly.SetStyleSetName("EpiReadOnly");
RuleAction epireadonlyOrderHed_chkPnyCcOrder_c = RuleAction.AddControlSettings(this.oTrans, "OrderHed.chkPnyCcOrder_c", controlSettings1EpiReadOnly);
RuleAction[] ruleActions = new RuleAction[] {
epireadonlyOrderHed_chkPnyCcOrder_c};
// Create RowRule and add to the EpiDataView.
RowRule rrCreateRowRuleOrderHednumPnyCcTransStatus_cGreaterThanOrEqualTo_10 = new RowRule("OrderHed.numPnyCcTransStatus_c", RuleCondition.GreaterThanOrEqualTo, 10, ruleActions);
((EpiDataView)(this.oTrans.EpiDataViews["OrderHed"])).AddRowRule(rrCreateRowRuleOrderHednumPnyCcTransStatus_cGreaterThanOrEqualTo_10);
// **** end autogenerated code ****
}
I found a work-around, using the BeforeCheckStateChanged event. But that fires every time the value changes, even on row changes and form loads, so I’m using it in combination with the Click event.
I define a public Boolean variable and initialize it to false in the InitializeCustomCode subroutine.
In the Checkbox_Click subroutine, which fires first, I set the Boolean variable to true.
In the Checkbox_BeforeCheckStateChanged subroutine, I check my conditions if the Boolean variable is true and set args.Cancel to true if my conditions are not met.
It’s more convoluted than I would like, but it’s working.