Skip to Content
author's profile photo Former Member
Former Member

Adding an item but not finding it

Hi

I can add an button to a form (the count property reflects that too) but i don't find it afterwards in the items - collection (you can reproduce the behaviour with the following code and by opening the businesspartners - form)

Tried with form.update,refresh but no success

TIA

Philipp


If pval.FormTypeEx="134" Then
	If  pval.BeforeAction=False And pval.EventType=SAPbouiCOM.BoEventTypes.et_FORM_LOAD Then
	' Button platzieren
	oForm=SBO_Application.Forms.Item(pval.FormUID)
	oItem = oForm.Items.Add("kit_1",SAPBouiCOM.BoFormItemTypes.it_BUTTON)
	oItem.Left=5
	oItem.Top=5
	oItem.Height=100
	oItem.Width=100
	oItem.Specific.Caption="Lala"
				
	For Each oItem In oForm.Items
	   If oItem.UniqueID="kit_1" Then
	    	SBO_Application.MessageBox("Halleluia")
	   End If
        Next

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    Posted on Dec 01, 2005 at 06:17 AM

    Philipp,

    Don't Add the the item and in the asme routine try to find it.

    1. Add it in a routine like on the form load.

    2. Find it in another routine like on a item pressed (button click).

    I've found this is one of the "features" of the UI API. In your example there is no need to "find" it after you've added it...

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2005 at 05:47 PM

    More Details...

    after adding another item it finds the first one.

    hmm somebody an idea?

    If pval.FormTypeEx="134" Then
    	If  pval.BeforeAction=False And pval.EventType=SAPbouiCOM.BoEventTypes.et_FORM_LOAD Then
    	' Button platzieren
    	oForm=SBO_Application.Forms.Item(pval.FormUID)
    	oItem = oForm.Items.Add("kit_1",SAPBouiCOM.BoFormItemTypes.it_BUTTON)
    	oItem.Left=5
    	oItem.Top=5
    	oItem.Height=100
    	oItem.Width=100
    	oItem.Specific.Caption="Lala"
    
    oItem = oForm.Items.Add("kit_2",SAPBouiCOM.BoFormItemTypes.it_BUTTON)
    oItem.Left=110
    oItem.Top=5
    oItem.Height=100
    oItem.Width=100
    oItem.Specific.Caption="Lala2"
    
    				
    	For Each oItem In oForm.Items
    	   If oItem.UniqueID="kit_1" Then
    	    	SBO_Application.MessageBox("Halleluia")
    	   End If
            Next
    

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.