on 07-03-2007 6:06 PM
Hi,
Please forgive my very first steps with SDK. I have a case where I call
SAPbouiCOM.Form fFAR = appSBO.Forms.Item("svcFAR");
to check if the form already exists. However, instead of null (the first time it doesn't exist), it throws an exception named 'Form - Invalid Form'...
Is this the correct way of checking if a Form already exists? I guess it should return 'null' instead...
Thanks,
Leo
Try something like this
Dim strUniqueID as String = "svcFAR"
Try
oForm = SBO_Application.Forms.Item(strUniqueID)
oForm.Select()
Catch ex As Exception
Dim fcp As SAPbouiCOM.FormCreationParams
fcp = SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_FormCreationParams)
fcp.BorderStyle = SAPbouiCOM.BoFormBorderStyle.fbs_Fixed
fcp.FormType = strFormType
'fcp.ObjectType =
fcp.UniqueID = strUniqueID
fcp.XmlData = loadFromXML(strXMLFile) 'function provided in SDK Samples
oForm = SBO_Application.Forms.AddEx(fcp)
End Try
Be sure to be looking for the correct form name. Sometimes you don't see it's name on the taskbar but the type.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can't believe something like 'Exists' was not implemented... or GetByKey, or similar..
anyway, I am following the try/catch approach...
But, I wanted to try also something like removing the form and creating it everytime (don't mind the overhead)... However, I can't find the RemoveEx???
form.Remove ("myForm")
... [createparams and stuff]
form.AddEx("myForm")
Is any way of removing the form so this can work?
Regards,
Leo
Hi Leonardo,
As there is no Exists property of the Forms collection, there is no immediate way to tell if a particular form is open. When dealing with my own forms (ie user forms which can only have one instance open), I use the following procedure to iterate through the forms collection. If the form is not found then I return null:
private SAPbouiCOM.Form SearchForm(string sType)
{
SAPbouiCOM.Form oForm;
for(int i = 0 ; i <= _sboApp.Forms.Count - 1; i++)
{
oForm = _sboApp.Forms.Item(i);
if (oForm.TypeEx == sType) return oForm;
}
return null;
}
Kind Regards,
Owen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
107 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.