UD Child Table Fields Read-only

I am working on a customization where I have added table UD05 as a child to DMRHead with the DMR number as the Key1 value. All of my fields are set up and work properly, however, I can’t get the fields bound to the UD05 table to change to read-only when the DMR is “closed” (the OpenDMR value is false).

The rest of the DMR Processing fields all become read-only when the record is closed and I would like to and need to have the UD05 fields do the same. What is the easiest way to do this? I’ve tested the following code below and it gets me close, but when I set the OpenDMR field to closed, it doesn’t grey out the UD05 field until the next time the DMR record is loaded. When the OpenDMR field is closed and I set it to open, however, the greyed-out UD05 field becomes active and available again. Any guidance is most appreciated.

private void edvDMRHead_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
{
	//var OpenDMR = (bool)view.dataView[view.Row]["OpenDMR"];
	// ** 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))
		{
			if(edvDMRHead.dataView.Table.Columns.Contains("OpenDMR"))
			{
				var OpenDMR = (bool)view.dataView[view.Row]["OpenDMR"];
				if(OpenDMR == true)
				{			
					MessageBox.Show("Open");
					this._edvUD05.dataView.Table.Columns["Character02"].ExtendedProperties["ReadOnly"] = false;
					this._edvUD05.dataView.Table.Columns["Character02"].ExtendedProperties["Enabled"] = true;
				}
				if(OpenDMR == false)
				{
					MessageBox.Show("Closed");
					this._edvUD05.dataView.Table.Columns["Character02"].ExtendedProperties["ReadOnly"] = true;
					this._edvUD05.dataView.Table.Columns["Character02"].ExtendedProperties["Enabled"] = false;
					
				}

			}
		}
	}
}

I have also tried adding a custom On Field Change event but had better luck with the EpiViewNotification event.

Perhaps more of a hack, but it’s easy… In the past, if I had fields that I wanted to mimic the readonly status of another field I simply used a OnPropertyChanged event on the child controls.

//Init
MyParentControl.PropertyChanged += PropertyChanged;
//Destroy
MyParentControl.PropertyChanged -= PropertyChanged;

private void PropertyChanged(object sender, Infragistics.Win.PropertyChangedEventArgs args)
{
MyComp1.ReadOnly = (sender as EpiTextBox).ReadOnly;
MyComp2.ReadOnly = (sender as EpiTextBox).ReadOnly;
//etc
}

@Chris_Conn Interesting! I will give this a try tomorrow and post the results. I appreciate the tip!

I’m gone two months and you abandon the EpiMagic… SIGH :sob:

1 Like

EpiMagic is black magic - if you dont sacrifice enough chickens it doesnt curse the right person. In this case, I tried (and failed) at using ExtendedProps on the views, the issue was my ExtendedProps were always overwritten by the data coming from db. So I cheated :stuck_out_tongue:

1 Like

@Chris_Conn, I tried your method and it worked for the all of my components that were EpiTextBox type. I can’t seem to get it to work for EpiCheckBox, EpiDateTimeEditor, or EpiCombo type fields.

I’ve used the following code and had the same results based on my initial attempt of using an EpiViewNotification event:

private void edvDMRHead_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
{
	//var OpenDMR = (bool)view.dataView[view.Row]["OpenDMR"];
	// ** 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))
		{
			if(edvDMRHead.dataView.Table.Columns.Contains("OpenDMR"))
			{
				var OpenDMR = (bool)view.dataView[view.Row]["OpenDMR"];
				if(OpenDMR == true)
				{	
					chkContain.ReadOnly = false;
					this._edvUD05.dataView.Table.Columns["CheckBox01"].ExtendedProperties["ReadOnly"] = false;
					this._edvUD05.dataView.Table.Columns["CheckBox01"].ExtendedProperties["Enabled"] = true;

					cmbNCRDept.ReadOnly = false;
					this._edvUD05.dataView.Table.Columns["ShortChar01"].ExtendedProperties["ReadOnly"] = false;
					this._edvUD05.dataView.Table.Columns["ShortChar01"].ExtendedProperties["Enabled"] = true;

					dteDisposition.ReadOnly = false;
					this._edvUD05.dataView.Table.Columns["Date01"].ExtendedProperties["ReadOnly"] = false;

					txtNCRDescription.ReadOnly = false;
					this._edvUD05.dataView.Table.Columns["Character01"].ExtendedProperties["ReadOnly"] = false;		
					txtDisposition.ReadOnly = false;
					this._edvUD05.dataView.Table.Columns["Character02"].ExtendedProperties["ReadOnly"] = false;
					txtFollowUp.ReadOnly = false;
					this._edvUD05.dataView.Table.Columns["Character03"].ExtendedProperties["ReadOnly"] = false;
					txtNoContainment.ReadOnly = false;
					this._edvUD05.dataView.Table.Columns["Character04"].ExtendedProperties["ReadOnly"] = false;
					txtNoCorrectiveAction.ReadOnly = false;
					this._edvUD05.dataView.Table.Columns["Character05"].ExtendedProperties["ReadOnly"] = false;
				}
				if(OpenDMR == false)
				{
					chkContain.ReadOnly = true;
					this._edvUD05.dataView.Table.Columns["CheckBox01"].ExtendedProperties["ReadOnly"] = true;
					this._edvUD05.dataView.Table.Columns["CheckBox01"].ExtendedProperties["Enabled"] = false;

					cmbNCRDept.ReadOnly = true;
					this._edvUD05.dataView.Table.Columns["ShortChar01"].ExtendedProperties["ReadOnly"] = true;
					this._edvUD05.dataView.Table.Columns["ShortChar01"].ExtendedProperties["Enabled"] = false;

					dteDisposition.ReadOnly = true;
					this._edvUD05.dataView.Table.Columns["Date01"].ExtendedProperties["ReadOnly"] = true;

					txtNCRDescription.ReadOnly = true;
					this._edvUD05.dataView.Table.Columns["Character01"].ExtendedProperties["ReadOnly"] = true;
					txtDisposition.ReadOnly = true;
					this._edvUD05.dataView.Table.Columns["Character02"].ExtendedProperties["ReadOnly"] = true;
					txtFollowUp.ReadOnly = true;
					this._edvUD05.dataView.Table.Columns["Character03"].ExtendedProperties["ReadOnly"] = true;
					txtNoContainment.ReadOnly = true;
					this._edvUD05.dataView.Table.Columns["Character04"].ExtendedProperties["ReadOnly"] = true;
					txtNoCorrectiveAction.ReadOnly = true;
					this._edvUD05.dataView.Table.Columns["Character05"].ExtendedProperties["ReadOnly"] = true;
				}
			}
		}
	}
}

I’ve tried combinations using the ExtendedProperty[“Enabled”] as well but to no avail. I’ve tried each option by itself, combined with one other, and combined with multiple. I’ve even tried setting something like:

chkContain.Enabled = false;

but I get a compile warning that .Enabled is obsolete and that ReadOnly should be used.

It almost seems like something is overriding the controls for the CheckBox, Combo, and Date fields. Any thoughts?

Epicor uses:

chkContain.IsEpiReadOnly = true;

and

this.txtReference5.EpiEnabledControl = true;

control.Enabled despite the warning from Epicor, is merely a .NET property, so you could also disable the warnings by placing this on top of your Customization. I do that as well, especially on some screens where I don’t even have an EpiBinding.

#pragma warning disable 0618, 0162

Another way that Epicor uses behind the scenes

ControlSettings cs = new ControlSettings();
cs.IsEnabled = true;
cs.IsReadOnly = false;
 
view.SetCurrentRowPropertyManually("EmailJT_c", cs);
view.SetCurrentRowProperty("EmailJT_c", cs);

EDIT:

Epicor tends to use .Enabled as well in a few UI Screens, but they use the following alot more, here is another one:

this.txtReference5.EpiEnabledControl = true;

and

this.txtReference1.EpiHiddenControl = false;
2 Likes

@hkeric.wci This is perfect! I can even get rid of the lines of code like:

this._edvUD05.dataView.Table.Columns[“CheckBox01”].ExtendedProperties[“ReadOnly”] = …

So much time messing around with only to have be something simple…classic. Is there somewhere to get a list of the Epi Control Properties for future reference?

I really appreciate the help.

Epicor tends to use .Enabled as well in a few UI Screens, but they use the following alot more, here is another one:

this.txtReference5.EpiEnabledControl = true;

and

this.txtReference1.EpiHiddenControl = false;
1 Like

I think the ExtendedProps will only work during Initialization, not during run-time (not dynamically). So yes, you have to use the other methods, or perhaps trigger a way for the form to re-evaluate the ExtendedProps.

:slight_smile: Ultimately, you should use RowRule’s. But the above does the trick too. I think @Rich can elaborate a bit more, why they don’t like you using .Enabled

1 Like

Enabled vs. Read-Only:

The Epicor UI uses Read-Only instead of Enabled as a WinForm control that is set “Enabled=False” will not take focus so there can be no Right Click Context Menu and the user cannot Select the data in the control to copy to the clipboard.

The Epicor UI also has special UI characteristics on Read-Only as we wanted the Read-Only controls to “Appear” disabled instead of appearing as Read-Only. Minor difference but makes for a much cleaner looking UI.

3 Likes

@Rich Thanks for the explanation/clarification!