cancel
Showing results for 
Search instead for 
Did you mean: 

EditText Help

Former Member
0 Kudos

Hello,

I have a edittext in my form that I created in Screen painter.

The EditText name as EditText1.

Before I click the Test Button, I input value in edittext.

But the problem is the edittext can't capture the value the I input after I click the Test Button.

It always NULL.

Please check my simple code.

If pVal.FormType = 2000060006 And pVal.Before_Action = False Then
                Select Case pVal.Action_Success
                    Case False

                    Case True
                        Select Case pVal.ItemUID
                            Case "Test"
                                Select Case pVal.EventType
                                    Case SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED
                                        Dim oEditText As SAPbouiCOM.EditText
                                        oEditText = oForm.Items.Item("EditText1").Specific

                                        If oEditText.String = "" Then
                                            SBO_Application.MessageBox("NULL")
                                        Else
                                            SBO_Application.MessageBox("NOT NULL")
                                        End If
                                End Select
                        End Select
                End Select
            End If

Accepted Solutions (1)

Accepted Solutions (1)

former_member682029
Contributor
0 Kudos

Better you add a user data source to that edit text. This is the proper way and so that the performance will be increased.

You can set / retrieve value associated with the edit text using this user data source with out any errors.

Thanks

Former Member
0 Kudos

Hi Anoop,

Where should I put that code?

Do you have a example?

former_member682029
Contributor
0 Kudos

You can do the code in loading the form.

sapbouicom.userdatarouce uds1 = form.datasources.userdatasources.add("udsname",...)
oeditText.databind.setbound(true,"","udsname")

Now the edit text is bound with datasource

Now you can use

uds1.valueEx

to read / set the value for the Edit text

Former Member
0 Kudos

Please translate it into VB.NET please.

Should I put that code in Item Event?

Select Case pVal.EventType
                            Case SAPbouiCOM.BoEventTypes.et_FORM_LOAD

former_member682029
Contributor
0 Kudos

You can use this code where ever you have the form object with you. Like Form load event, or loading the XML etc.

Public Sub UsingUserDataSource()

    Dim oForm As SAPbouiCOM.Form
    Dim oEditText As SAPbouiCOM.EditText

    '// Add a form
    Set oForm = SBO_Application.Forms.Add("SimpleForm")

    '// Add a user data source to the form
    oForm.DataSources.UserDataSources.Add "EditSource", dt_SHORT_TEXT, 20

    '//*************************
    '// Adding a Text Edit item
    '//*************************
    Set oEditText = oForm.Items.Add("EditText1", it_EDIT).Specific

    '// Bind the text edit item to the user data source
    oEditText.DataBind.SetBound True, "", "EditSource"

End Sub

Answers (0)