Skip to Content
0
Former Member
Mar 16, 2009 at 05:17 PM

set form items to enable or disable according to the value of a UDF

867 Views

Dear all,

I have a form generated from UDO consisting of some edittext objects and a matrix object. I tried to add a status field to the form and hope it works like the status field in the PO or Order. The UI for the status field is designed as a combobox with three valid values. What I want is when I navigate the datasource, if the value of status field is "cancelled", the other objects like edittext and matrix will be set to disable. I developed the project under B1TE.

1. The first question is which event should I put the codes on?

2. After many search and tries, I now put the codes on the et_MATRIX_LOAD event as following,

<B1Listener(BoEventTypes.et_MATRIX_LOAD, False)> _
        Public Overridable Sub OnAfterMatrixLoad(ByVal pVal As ItemEvent)
            Dim ActionSuccess As Boolean = pVal.ActionSuccess
            Dim form As Form = B1Connections.theAppl.Forms.Item(pVal.FormUID)
            Dim item As Item = form.Items.Item("mtx_0")
            Dim matrix As Matrix = CType(item.Specific, Matrix)
            'ADD YOUR ACTION CODE HERE ...
            Dim item1 As Item = form.Items.Item("22")
            Dim oCombobox As ComboBox = CType(item1.Specific, ComboBox)
            Dim oString As String
            oString = oCombobox.Selected.Value
            Dim oEnable As Boolean
            If oString = "1" Or oString = "2" Then
                oEnable = False
            Else
                oEnable = True
            End If
            Dim oActive As EditText
            oActive = form.Items.Item("3").Specific
            oActive.Active = True
            form.Items.Item("5").Enabled = oEnable
            form.Items.Item("7").Enabled = oEnable
            form.Items.Item("9").Enabled = oEnable
            form.Items.Item("13").Enabled = oEnable
            form.Items.Item("19").Enabled = oEnable
            form.Items.Item("22").Enabled = oEnable
            form.Items.Item("add").Enabled = oEnable
            form.Items.Item("del").Enabled = oEnable
            form.Items.Item("mtx_0").Enabled = oEnable
        End Sub

An error occuried on "Dim oCombobox As ComboBox = CType(item1.Specific, ComboBox)".

Espect your replies. Thanks.