Customization Enable/Disable All Controls in an EpiGroupBox

We have a need to add multiple controls for UD fields to a customization (still in the Classic UI). These fields will all go together in a single group box. Kinetic has instances where all of the fields in a group box are enabled/disabled by a single checkbox on the form. (See SalesOrder > Header Manifest > General Intl.) How to we tap into the mechanism that Kinetic uses to do this? EpiGroupBox does not have support for iterating over the controls within it. At best, enumerating each field GUID by GUID is cumbersome. Currently doing something like this:

		EpiDateTimeEditor dteEUARcvd = ((EpiDateTimeEditor)csm.GetNativeControlReference("8f582073-74e1-4284-89d5-2cb531f713d7"));
		dteEUARcvd.IsEpiReadOnly = Read_Only;

Oh but it does…

	UD01Form.Text = "";
	foreach(Control ctl in epiGroupBoxC1.Controls)
	{
		UD01Form.Text += ctl.Name + " ";
	}
2 Likes

Thank you for correcting me and for your example. My original foreach had a typo that led to a misleading error that there was no built-in enumerator for that class. I learned it takes a little more fiddling to be able to do anything with the controls once you have them:

		foreach (Control c in IntGrp.Controls)
		{
			if (c.GetType().Name != "EpiLabel")
			{
				switch (c.GetType().Name)
				{
					case "EpiTextBox":
						EpiTextBox ctlTxt = (EpiTextBox)c;
						ctlTxt.IsEpiReadOnly = Read_Only;
						break;
					case "EpiCheckBox":
						EpiCheckBox ctlChk = (EpiCheckBox)c;
						ctlChk.IsEpiReadOnly = Read_Only;
						break;
					case "EpiDateTimeEditor":
						EpiDateTimeEditor ctlDTE = (EpiDateTimeEditor)c;
						ctlDTE.IsEpiReadOnly = Read_Only;
						break;
					case "EpiCurrencyEditor":
						EpiCurrencyEditor ctlCur = (EpiCurrencyEditor)c;
						ctlCur.IsEpiReadOnly = Read_Only;
						break;
				}
			}
		}
1 Like

You’re welcome Mr. ChickenDance

Chicken Dance GIF

If you disable the Group box itself, the controls within it automatically become disabled.

3 Likes

Forest-For-Trees

Interesting because that is not the way Epicor handles it. I had added my fields into an existing GroupBox that is controlled by an existing checkbox. When checked, the fields in the GroupBox are enabled. However, when unchecked, the original fields in the GroupBox are disabled, but the fields I added are not. My fields maintained the state set in the designer regardless of the status of the checkbox.

I would drop your UD fields into a new group box then, and just control the enabled state of it.

Trigger using the EpiViewNotification, filtered for event type Initialize.

private void edvJobHead_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
	{
		// ** Argument Properties and Uses **
		// view.dataView[args.Row]["FieldName"]
		// args.Row, args.Column, args.Sender, args.NotifyType
		// NotifyType.Initialize, NotifyType.AddRow, NotifyType.DeleteRow, NotifyType.InitLastView, NotifyType.InitAndResetTreeNodes
		if ((args.NotifyType == EpiTransaction.NotifyType.Initialize))
		{
			if ((args.Row > -1))
			{
				bool myCheckBox = (bool)view.dataView[args.Row]["MyCheckBox_c"];
			
				if(myCheckBox)
                {
                     grpMyGroup.Enabled = false;
                }		
	            else
                {
                     grpMyGroup.Enabled = true;
                }
			}
		}
	}

Make sure to create the event properly using the wizard - just copying and pasting from here won’t setup the triggers.