E10: How to manage the binded controls ReadOnly property

I am trying create a customization that will either be a tracker or an entry screen based on the Security Group. I feel like I am battling the system on controlling the ReadOnly property. I set the ReaOnly property in the load function, but the controls still are getting enabled (or ReadOnly = false) .

Do you think that I need to unbind the objects and place a set function on the AfterAdapter method for GetById or GetNew?

1 Like

Have you considered using a customization wizard to set the extended properties of the data-view to be read-only? That’s the cleanest way to work with native properties, in my opinion. If a control is tied to a bound data view column, it will make that control read only.

I didn’t do that exactly. I did it in a method and called that method in the Load method. I will try it, just to cover all the bases.

Yes, that makes sense. The wizard does the exact same thing but calls the method in the InitializeCustomCode method, and again goes after the dataview not the control itself…

> private void SetExtendedProperties()
> 	{
> 		// Begin Wizard Added EpiDataView Initialization
> 		EpiDataView edvQuoteDtl = ((EpiDataView)(this.oTrans.EpiDataViews["QuoteDtl"]));
> 
> 		// End Wizard Added EpiDataView Initialization
> 
> 		// Begin Wizard Added Conditional Block
> 		if (edvQuoteDtl.dataView.Table.Columns.Contains("ShortChar01"))
> 		{
> 			// Begin Wizard Added ExtendedProperty Settings: edvQuoteDtl-ShortChar01
> 			edvQuoteDtl.dataView.Table.Columns["ShortChar01"].ExtendedProperties["ReadOnly"] = true;
> 			// End Wizard Added ExtendedProperty Settings: edvQuoteDtl-ShortChar01
> 		}
> 	}
2 Likes

Well that worked, for the most part. With a few adjustments:

  1. Move the SetExtendedProperties() method to the Load method. The behavior was the same
  2. I added all the fields I needed.

the problem I am finding is that it does not seem to impact DateTime objects or comboboxes. It only seems to work on TextBoxes

But my original issue is resolved. Thank you.

So in working on my next issue in trying to gain control of the Enable/Disable properties of all the controls (TextBoxes, DateTimeEditor, NumericEditor, epiCombo, and UltraGrids), I found out that:

  1. don’t use the Enabled property
  2. for TextBoxes, you can use the wizard to alter the ExtendedProperty of ReadOnly
  3. for ComboBoxes, DateTimeEditor,and grids, I edited the “IsEpiReadOnly” property on the control itself.

Does anyone see any issue of me doing it this way?

Are you trying to set the entire form in read only? Why are you setting the value to so many controls? Just curious as to what the end goal is

@josecgomez, you have me very curious. Yes, I am trying to set the entire form to read only. Are you suggesting that there maybe a way to just set the form to ReadOnly and not each individual control?

Yes, you can do this with menu maintenance.

1 Like

Yeah ti’s pretty trivial hehe

Form.IsReadOnly =true; :slight_smile:

This can be done in code (as above)
or in Menu Maintenance via a CheckBox (Read Only)

1 Like

Ok @josecgomez @danbedwards and everyone else that thought it, yes that is pie in my face. I am working on a whole new process in Epicor and thinking about everything, I set myself down a path forgetting to backup every once in a while to re-evaluate what the heck am I doing and is this the right way to do it.

A simple line of UD100Form.IsEpiReadOnly = true; in the Load method replaced 100 lines of code, in the SetExtendedProperties() method, that set the ReadOnly extended property of each DataField to UD100 and UD100A AND the ComboBoxes and DateTimeEditors that the extended property didn’t impact.

I know this got long quick, so thank you guys. Maybe I should just talk out loud in the forum more often.

3 Likes