Toggle Read Only based on a checkbox

I am trying to force two text boxes to be read only if a checkbox is false, and when the checkbox is true, make the text boxes be editable. I am pulling my hair out. Both text boxes are bound, as is the checkbox triggering them. If I modify the extended properties, it seems to disable being able to toggle them read only via the checked change event on the Checkbox. If I changed the IsEpiReadOnly property on them, it almost seems to work in reverse of the logic I would expect. But even then, it doesn’t set the read only when the form loads based on the current value as the form is loaded.

	private void chkDynamicPrefix_CheckedChanged(object sender, System.EventArgs args)
	{
		if (Convert.ToBoolean(edvPart.dataView[edvPart.Row]["DynamicSNPrefix_c"]) == true)
		{
			txtPrefixAbbr.IsEpiReadOnly = true;
			txtDateCode.IsEpiReadOnly = true;
		}
		else
		{
			txtPrefixAbbr.IsEpiReadOnly = false;
			txtDateCode.IsEpiReadOnly = false;
		}
	}

If it matters, I am working in the SN Prefix screen. My goal is to add the ability to make a date code in the SN Prefix field for a numeric serial number that auto updates itself with each week. Masking does not suit us because it will not let us enter a range of serial numbers.

Try using AfterCheckStateChanged event, its my go to event for this kind of thing.

1 Like

Are those two boxes you want to control bound to fields? If so try changing the state of the edv instead of the UI

1 Like

I think the Row Rule Wizard is your friend here. Row Rules know how to master all the EpiMagic that is going on in the UI (which I’m guessing is interfering in some way, causing your code to not work).

2 Likes

This was the exact right thing. I didn’t know this thing existed on the customization screen. Thanks!

1 Like