Checkbox Read Only

How do you make a rule that would make a checkbox read only after its been checked. Would this be rule wizard or event? Every time i try and make a rule for it in customization it doesnt work.

Assuming the checkbox is bound to a field you can use a Row Rule. Here is example
image

that is how I did it before, but it wont lock after I check it2017-11-08_10-53-59.pdf (31.6 KB)

Odd. That definitely looks correct. I assume the checkbox on your screen has the EpiBinding to FirmReleaseAll_c?

Can you paste the code from the script editor just to see if perhaps something is off?

yes that is correct

// **************************************************
// Custom code for SalesOrderForm
// Created: 10/28/2016 9:01:16 AM
// **************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Erp.Adapters;
using Erp.UI;
using Ice.Lib;
using Ice.Adapters;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;

public class Script
{
// ** Wizard Insert Location - Do Not Remove ā€˜Begin/End Wizard Added Module Level Variablesā€™ Comments! **
// Begin Wizard Added Module Level Variables **

// End Wizard Added Module Level Variables **

// Add Custom Module Level Variables Here **

public void InitializeCustomCode()
{
	// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
	// Begin Wizard Added Variable Initialization

	// End Wizard Added Variable Initialization

	// Begin Wizard Added Custom Method Calls

CreateRowRuleOrderHedFirmReleaseAll_cEquals_true();;;
// End Wizard Added Custom Method Calls

	SetExtendedProperties();
}

public void DestroyCustomCode()
{
	// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
	// Begin Wizard Added Object Disposal


	// Begin Custom Code Disposal

	// End Custom Code Disposal
}

private void SetExtendedProperties()
{
	// Begin Wizard Added EpiDataView Initialization
	EpiDataView edvOrderDtl = ((EpiDataView)(this.oTrans.EpiDataViews["OrderDtl"]));
	EpiDataView edvOrderHed = ((EpiDataView)(this.oTrans.EpiDataViews["OrderHed"]));
	// End Wizard Added EpiDataView Initialization

	// Begin Wizard Added Conditional Block
	if (edvOrderDtl.dataView.Table.Columns.Contains("DocUnitPrice"))
	{
		// Begin Wizard Added ExtendedProperty Settings: edvOrderDtl-DocUnitPrice
		edvOrderDtl.dataView.Table.Columns["DocUnitPrice"].ExtendedProperties["Enabled"] = true;
		edvOrderDtl.dataView.Table.Columns["DocUnitPrice"].ExtendedProperties["Format"] = "999,999.99";
		// End Wizard Added ExtendedProperty Settings: edvOrderDtl-DocUnitPrice
	}
	if (edvOrderHed.dataView.Table.Columns.Contains("OrderType_c"))
	{
		// Begin Wizard Added ExtendedProperty Settings: edvOrderHed-OrderType_c
		edvOrderHed.dataView.Table.Columns["OrderType_c"].ExtendedProperties["Enabled"] = true;
		// End Wizard Added ExtendedProperty Settings: edvOrderHed-OrderType_c
	}
	if (edvOrderDtl.dataView.Table.Columns.Contains("DocListPrice"))
	{
		// Begin Wizard Added ExtendedProperty Settings: edvOrderDtl-DocListPrice
		edvOrderDtl.dataView.Table.Columns["DocListPrice"].ExtendedProperties["Format"] = ">>>.>>9.99";
		// End Wizard Added ExtendedProperty Settings: edvOrderDtl-DocListPrice
	}
	// End Wizard Added Conditional Block
}




private void CreateRowRuleOrderHedFirmReleaseAll_cEquals_true()
{
	// Description: LockFirmReleaseAll
	// **** begin autogenerated code ****
	RuleAction disabledOrderHed_FirmReleaseAll_c = RuleAction.AddControlSettings(this.oTrans, "OrderHed.FirmReleaseAll_c", SettingStyle.Disabled);
	RuleAction[] ruleActions = new RuleAction[] {
			disabledOrderHed_FirmReleaseAll_c};
	// Create RowRule and add to the EpiDataView.
	RowRule rrCreateRowRuleOrderHedFirmReleaseAll_cEquals_true = new RowRule("OrderHed.FirmReleaseAll_c", RuleCondition.Equals, true, ruleActions);
	((EpiDataView)(this.oTrans.EpiDataViews["OrderHed"])).AddRowRule(rrCreateRowRuleOrderHedFirmReleaseAll_cEquals_true);
	// **** end autogenerated code ****
}

}

Iā€™m running into similar issues. Checkbox control not recognized by a rule setting. Also canā€™t affect it with ExtendedProperties on the dataview column or changing an unbound checkbox control. Very annoying.

I got it to work on custom fields. Here is the code from the Customization screen.

Oh, and the proper extended property is ā€œRead Onlyā€ not ā€œEnabledā€. That tripped me up when I was trying to do it too.

public void InitializeCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
		// Begin Wizard Added Variable Initialization

		// End Wizard Added Variable Initialization

		// Begin Wizard Added Custom Method Calls

		this.epiCheckBoxC1.CheckStateChanged += new System.EventHandler(this.epiCheckBoxC1_CheckStateChanged);
		this.epiCheckBoxC2.CheckStateChanged += new System.EventHandler(this.epiCheckBoxC2_CheckStateChanged);

		// End Wizard Added Custom Method Calls
	}

	public void DestroyCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
		// Begin Wizard Added Object Disposal

		this.epiCheckBoxC1.CheckStateChanged -= new System.EventHandler(this.epiCheckBoxC1_CheckStateChanged);
		this.epiCheckBoxC2.CheckStateChanged -= new System.EventHandler(this.epiCheckBoxC2_CheckStateChanged);

		// End Wizard Added Object Disposal

		// Begin Custom Code Disposal

		// End Custom Code Disposal
	}

	private void epiCheckBoxC1_CheckStateChanged(object sender, System.EventArgs args)
	{
		if (epiCheckBoxC1.Checked = true)
		{
			//private void SetExtendedProperties()
			{
			// Begin Wizard Added EpiDataView Initialization
				EpiDataView edvPart = ((EpiDataView)(this.oTrans.EpiDataViews["Part"]));
			// End Wizard Added EpiDataView Initialization

			// Begin Wizard Added Conditional Block
				if (edvPart.dataView.Table.Columns.Contains("NPI_c"))
				{
				// Begin Wizard Added ExtendedProperty Settings: edvPart-NPI_c
					edvPart.dataView.Table.Columns["NPI_c"].ExtendedProperties["Read Only"] = true;
				// End Wizard Added ExtendedProperty Settings: edvPart-NPI_c
				}
			// End Wizard Added Conditional Block
			}
		}
	}
1 Like

Hi,

Iā€™m trying to do a similar thing on the order page with a UD checkbox but for some reason nothing is happening. The field does not become read only after itā€™s checked. Is there something Iā€™m missing?

This is the code I used.

public void InitializeCustomCode()
{
// ** Wizard Insert Location - Do not delete ā€˜Begin/End Wizard Added Variable Initializationā€™ lines **
// Begin Wizard Added Variable Initialization

	// End Wizard Added Variable Initialization

	// Begin Wizard Added Custom Method Calls

	this.chkWarranty.CheckStateChanged += new System.EventHandler(this.chkWarranty_CheckStateChanged);
			
	// End Wizard Added Custom Method Calls
}

public void DestroyCustomCode()
{
	// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
	// Begin Wizard Added Object Disposal

	this.chkWarranty.CheckStateChanged -= new System.EventHandler(this.chkWarranty_CheckStateChanged);
	

	// End Wizard Added Object Disposal

	// Begin Custom Code Disposal

	// End Custom Code Disposal
}

private void chkWarranty_CheckStateChanged(object sender, System.EventArgs args)
{
	if (chkWarranty.Checked = true)
	{
	
		// Begin Wizard Added EpiDataView Initialization
			EpiDataView edvOrderHed = ((EpiDataView)(this.oTrans.EpiDataViews["OrderHed"]));
		// End Wizard Added EpiDataView Initialization

			// Begin Wizard Added Conditional Block
			if (edvOrderHed.dataView.Table.Columns.Contains("Warranty_c"))
			{
				//Begin Wizard Added ExtendedProperty 
					edvOrderHed.dataView.Table.Columns["Warranty_c"].ExtendedProperties["ReadOnly"] = true;
				// End Wizard Added ExtendedProperty 
			}
			// End Wizard Added Conditional Block
		
	}
}

I managed to get this working using the Row rule. :slight_smile:

thanks

1 Like