Errors setting UltraGrid column to read only

This is a child of topicRead only on grid.
The wizard created the code but it blows up. Previously I added a combo-box to the same ultragrid “grdPCO” and use the same to catch users deleting lines via the DEL keyboard key. Those all worked until now.

VS says it’s Null Reference Exceptions but Epicor shows the two errors below. Been going down a few roads on troubleshooting but so far coming up blank. The code it’s bombing on is:

    private void SetExtendedProperties()
    {
		EpiDataView edvUD28View = ((EpiDataView)(this.oTrans.EpiDataViews["pcoGrid"]));
		if (edvUD28View.dataView.Table.Columns.Contains("CheckBox01"))
		{
			edvUD28View.dataView.Table.Columns["CheckBox01"].ExtendedProperties["ReadOnly"] = true;   //PCO is Submitted
		}
    }

    private void SalesOrderForm_Load(object sender, EventArgs args)
    {
        pcoGrid.DisplayLayout.Bands[0].Columns["ShortChar01"].ValueList = cmbPCOTypes;
        pcoGrid.DisplayLayout.Bands[0].Columns["ShortChar01"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
        cmbPCOTypes.ForceRefreshList();
		
		this.pcoGrid.KeyActionMappings.Add(
		new GridKeyActionMapping(
			// the key code
			Keys.Delete,
			// the action to take
	   	 0,  //UltraGridAction.FirstRowInGrid,
			// disallowed state
			0, 
			// required state (none)
			UltraGridState.InEdit,
			// disallowed special keys
			0, //(none)  //Infragistics.Win.SpecialKeys.Alt,
			// required special keys (none)
			0 ) );
    }

Application Error

Exception caught in: mscorlib

Error Detail 
============
Message: Exception has been thrown by the target of an invocation.
Inner Exception Message: Object reference not set to an instance of an object.
Program: CommonLanguageRuntimeLibrary
Method: InvokeMethod

Client Stack Trace 
==================
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Ice.Lib.Customization.CustomScriptMethodInvoker.InvokeScriptMethod(MethodInfo scriptMethod, Object[] parameters)
   at Ice.Lib.Customization.CustomScriptMethodInvoker.InvokeCustomFormLoadIfExists(String methodName, Object sender, EventArgs e)
   at Ice.Lib.Customization.CustomScriptManager.<>c__DisplayClass103_0.<OnCustomCodeFormLoad>b__0()
   at Ice.Lib.Customization.CustomScriptManager.TryActionShowExceptionBoxOrLogVerificationErrorIfException(Action action, String exceptionBoxTitle)

Inner Exception 
===============
Object reference not set to an instance of an object.



   at Script.SalesOrderForm_Load(Object sender, EventArgs args) in c:\ProgramData\Epicor\azeislaapp02vm.elkay.elkaymfgco.com-443\3.2.200.0\ISI\CustomDLLs\App.SalesOrderEntry.SalesOrderForm.EP.ISI.Customization.OrderEntryPCO.CustomCode.16.cs:line 5660
Application Error

Exception caught in: Ice.Lib.EpiClientLib

Error Detail 
============
Message: Control 'grdPCO' of type EpiUltraGrid has an invalid binding to view UD28View.
Program: Ice.Lib.EpiClientLib.dll
Method: EventSetup

Client Stack Trace 
==================
   at Ice.Lib.Framework.EpiUltraGrid.EventSetup()
   at Ice.Lib.Framework.EpiUltraGrid.set_EpiTransaction(IEpiTransaction value)
   at Ice.Lib.Framework.EpiUIUtils.BindNConfigureControls()
```

The line above seems odd. Is the EpiDataView really called “pcoGrid”?
Also, when are you creating the EpiDataView? It should be happening in the Initialize code (or referenced from there).

Good catch, I’ve been troubleshooting and had changed the Wizard created code. I missed that when making the post. Oddly, it did put that line at the top of the Extended function, I just cut out unrelated code in between and forgot to copy/paste the original. I changed it to the manually created pcoGrid but in troubleshooting but it’s throwing the same errors.

A case of dueling declarations? I used the wizard to add the UD as child and others plus some manually for the combo-box on grid and capture of DEL key. Set pcoGrid to reference UD28View?

Script, Initialize, and fixed Extended is:

public class Script
{
    private UD28Adapter _ud28Adapter;
    private EpiDataView _edvOrderHed;
    private DataTable UD28_Column;
    private EpiDataView _edvUD28;
    private string _Key1UD28;
    private string _Key2UD28;
    private string _Key3UD28;
    private string _Key4UD28;
    private string _Key5UD28;
    private DataView OrderHed_DataView;
    EpiUltraGrid pcoGrid;  //Custom added to set combo on grid and capture DEL key
}

public void InitializeCustomCode()
{
    InitializeUD28Adapter();
    this._Key1UD28 = string.Empty;
    this._Key2UD28 = string.Empty;
    this._Key3UD28 = string.Empty;
    this._Key4UD28 = string.Empty;
    this._Key5UD28 = string.Empty;
    this.baseToolbarsManager.ToolClick += new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(this.baseToolbarsManager_ToolClickForUD28);
    this.SalesOrderForm.BeforeToolClick += new Ice.Lib.Framework.BeforeToolClickEventHandler(this.SalesOrderForm_BeforeToolClickForUD28);
    this.SalesOrderForm.AfterToolClick += new Ice.Lib.Framework.AfterToolClickEventHandler(this.SalesOrderForm_AfterToolClickForUD28);
    this.OrderHed_Row.EpiRowChanged += new EpiRowChanged(this.OrderHed_AfterRowChangeForUD28);
    this.OrderHed_DataView = this.OrderHed_Row.dataView;
    this.OrderHed_DataView.ListChanged += new ListChangedEventHandler(this.OrderHed_DataView_ListChangedForUD28);
    this.OrderHed_Row.BeforeResetDataView += new Ice.Lib.Framework.EpiDataView.BeforeResetDataViewDelegate(this.OrderHed_BeforeResetDataViewForUD28);
    this.OrderHed_Row.AfterResetDataView += new Ice.Lib.Framework.EpiDataView.AfterResetDataViewDelegate(this.OrderHed_AfterResetDataViewForUD28);
    pcoGrid = (EpiUltraGrid)csm.GetNativeControlReference("0463137c-9dbf-4811-97c5-80b229cf9f3f");
    gatherRows = new List<UltraGridRow>();
    this.btnSubmitToProd.Click += new System.EventHandler(this.btnSubmitToProd_Click);
    this.btnNewPCObyLine.Click += new System.EventHandler(this.btnNewPCObyLine_Click);
    EpiTextBox txtNewPCObyLine = (EpiTextBox)csm.GetNativeControlReference("bfba4fba-8c19-47a7-a488-533eebc0f9b0");
     this.btnDeleteSelected.Click += new System.EventHandler(this.btnDeleteSelected_Click);
     this.grdPCO.BeforeRowsDeleted += new Infragistics.Win.UltraWinGrid.BeforeRowsDeletedEventHandler(this.grdPCO_BeforeRowsDeleted);
     this.grdPCO.KeyDown += new System.Windows.Forms.KeyEventHandler(this.grdPCO_KeyDown);
}

private void SetExtendedProperties()
{
	EpiDataView edvUD28View = ((EpiDataView)(this.oTrans.EpiDataViews["UD28View"]));

	if (edvUD28View.dataView.Table.Columns.Contains("CheckBox01"))
	{
	   edvUD28View.dataView.Table.Columns["CheckBox01"].ExtendedProperties["ReadOnly"] = true;   //PCO is Submitted
	}
}

Once again I was making it harder than it needed to be: