SAP B1 Error: 'Item - Can't set value on item because the item can't get focus. [66000-153]'

SAP B1 Error: 'Item - Can't set value on item because the item can't get focus. [66000-153]'

我正在使用 SAP B1 Studio 制作 2 个编辑文本,并从 CardCode 和 CardName 列表中进行选择。我不断收到错误“错误:”项目 - 无法在项目上设置值,因为该项目无法获得焦点。 [66000-153]' 在我从 2.

中的任何一个中做出选择之后

有什么问题吗?

这是我使用的代码:

this.txtCCode = ((SAPbouiCOM.EditText)(this.GetItem("txtCCode").Specific));
txtCCode.ChooseFromListAfter += txtCCode_ChooseFromListAfter;
this.txtCName = ((SAPbouiCOM.EditText)(this.GetItem("txtCName").Specific));
txtCName.ChooseFromListAfter += txtCName_ChooseFromListAfter;

private void txtCCode_ChooseFromListAfter(object sboObject, SAPbouiCOM.SBOItemEventArg pVal)
        {
            try
            {
                SAPbouiCOM.ISBOChooseFromListEventArg oCFLEvento = (SAPbouiCOM.ISBOChooseFromListEventArg)(pVal);
                string sCFL_ID = oCFLEvento.ChooseFromListUID;
                SAPbouiCOM.DataTable dt = oCFLEvento.SelectedObjects;               
                txtCName.Value = dt.GetValue("CardName", 0).ToString();
                txtCCode.Value = dt.GetValue("CardCode", 0).ToString();
            }
            catch (Exception ex)
            {
                Application.SBO_Application.SetStatusBarMessage("Error: '" + ex.Message + "'", SAPbouiCOM.BoMessageTime.bmt_Short, true);
            }
        }

        private void txtCName_ChooseFromListAfter(object sboObject, SAPbouiCOM.SBOItemEventArg pVal)
        {
            try
            {
                SAPbouiCOM.ISBOChooseFromListEventArg oCFLEvento = (SAPbouiCOM.ISBOChooseFromListEventArg)(pVal);
                string sCFL_ID = oCFLEvento.ChooseFromListUID;
                SAPbouiCOM.DataTable dt = oCFLEvento.SelectedObjects;
                txtCCode.Value = dt.GetValue("CardCode", 0).ToString();
                txtCName.Value = dt.GetValue("CardName", 0).ToString();
            }
            catch (Exception ex)
            {
                Application.SBO_Application.SetStatusBarMessage("Error: '" + ex.Message + "'", SAPbouiCOM.BoMessageTime.bmt_Short, true);
            }
        }

如果所有内容都正确绑定到 editText 并且配置了 ChooseFromList,我会尝试从您的第一种方法中删除以下内容:

 txtCCode.Value = dt.GetValue("CardCode", 0).ToString();

因为它应该会自动填写。

其他一些可能:

尝试设置字符串而不是值

    txtCCode.String = 

尝试在设置值之前将另一个项目设置为活动状态

   myOtherControl.Active = True

尝试在 dbDatasource 中设置值:

  Dim oDBDataSource As SAPbouiCOM.DBDataSource = form.DataSources.DBDataSources.Item("OCRD")
  oDBDataSource.SetValue("CardCode", 0, dt.GetValue("CardCode", 0))