Hi Edward,
1. The order of events are the following:
ItemEvent - FormLoad - BeforeAction = true
FormDataEvent - FormDataLoad - BeforeAction = true
FormDataEvent - FormDataLoad - BeforeAction = false
ItemEvent - FormLoad - BeforeAction = false
In the last sample code, we clear the matrix before SAP loads the data for the form, then your matrix shouldn't be empty. (I use SAP B1 9.0 PL 11). For me, it works.
2. About select more than one checkbox, I created a UserDataSource and use it to bound my checkbox column.
Looks the code:
if(pVal.EventType == SAPbouiCOM.BoEventTypes.et_FORM_LOAD && pVal.FormTypeEx.Equals("139") && pVal.BeforeAction) { SAPbouiCOM.Form oForm = objApp.Forms.GetFormByTypeAndCount(Convert.ToInt32(pVal.FormTypeEx), pVal.FormTypeCount); SAPbouiCOM.UserDataSource oUds = oForm.DataSources.UserDataSources.Add("U_Selected", SAPbouiCOM.BoDataType.dt_LONG_TEXT, 2); SAPbouiCOM.Matrix oMatrix = (SAPbouiCOM.Matrix)oForm.Items.Item("38").Specific; int count = oMatrix.RowCount; oMatrix.Clear(); oMatrix.Columns.Add("chkShpDte", SAPbouiCOM.BoFormItemTypes.it_CHECK_BOX); SAPbouiCOM.Column oColumn = oMatrix.Columns.Item("chkShpDte"); oColumn.TitleObject.Caption = "Ship Sel"; oColumn.DataBind.SetBound(true, "", "U_Selected"); oMatrix.AddRow(count, oMatrix.RowCount); }
But, I believe that the right way is to create an UDF as you mentioned. The code above works as expected in my SAP B1 version.
Hope it helps.
Best regards,
Diego Lother