Skip to Content
avatar image
Former Member

How do I set focus on a control on a form.

Hello All,

Dim oForm As SAPbouiCOM.Form

Dim oItem As SAPbouiCOM.Item

Dim oItem2 As SAPbouiCOM.Item

Set oForm = SBO_Application.Forms.Add("SimpleForm", ft_Fixed)

Set oItem = oForm.Items.Add("1", it_BUTTON)

Set oItem2 = oForm.Items.Add("1", it_BUTTON)

It is easy to add these to items to the form. The form itself has a "Select" method which enables it to receive the focus. But how do you set the focus on one of these items or the other? There isn't a "Select" or "SetFocus" Method on either the item or the underlying control object.

Any Help or comments appreciated.

- Mel

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • avatar image
    Former Member
    Aug 11, 2004 at 07:35 PM

    Generally you cannot set focus to many different controls. It seems to be limited to EditText and ComboBox and perhaps a couple others.

    You set focus with the click method.

    In your example, you might want to set the default button for the form instead.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Bruce,

      Thanks for your reply. However, neither the edit text or combo box objects have a click method - only a click event. Could you (or anyone) give a short example of setting focus to an edit text object on a form?

      Thanks,

      - Mel

  • avatar image
    Former Member
    Aug 12, 2004 at 03:48 PM

    Hi,

    if i understand your problem:

    'I force the Focus in field Code Item (with itemUID=5)

    frm.Items.Item("5").Click (BoCellClickType.ct_Regular)

    Best Regards

    Serema

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Mel,

      To clarify this a little more, you must use the item click method. This can be used with any type of item, so for this method you do not go down to the item.specific (which may be an EditText, etc.) That is what you need to see in Serema's code.

      --Bruce

  • avatar image
    Former Member
    Aug 12, 2004 at 06:01 PM

    Thanks Serema and all,

    Serema's code resolved it. I was looking at the "specific" attributes and needed to check the regular.

    Mel

    Add comment
    10|10000 characters needed characters exceeded