cancel
Showing results for 
Search instead for 
Did you mean: 

Add Row Number UDO Matrix

Former Member
0 Kudos
119

Dear All,

   How to Add Row Number in UDO Matrix? I am using below code.

'Declare Variables

Private WithEvents SBO_Application As SAPbouiCOM.Application

        Private WithEvents oForm As SAPbouiCOM.Form = Nothing

        Private WithEvents oItem As SAPbobsCOM.Items

        Private WithEvents oMatrix As SAPbouiCOM.Matrix

  Public Sub New()

            SBO_Application = SAPbouiCOM.Framework.Application.SBO_Application

            oForm = Me.UIAPIRawForm

            oForm = SBO_Application.Forms.ActiveForm()

              End Sub

Private Sub SBO_Application_ItemEvent(FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.ItemEvent

            Try

                Select Case pVal.Before_Action

                    Case True

                        Select Case pVal.EventType

                            Case SAPbouiCOM.BoEventTypes.et_FORM_CLOSE

                                flag = 1

                        End Select

                    Case False

                        Select Case pVal.EventType

                            Case SAPbouiCOM.BoEventTypes.et_FORM_ACTIVATE

                                frmUid = pVal.FormUID

                                If flag = 0 Then

                                    oForm = SBO_Application.Forms.ActiveForm()

                                    oForm = DirectCast(SBO_Application.Forms.Item(frmUid), SAPbouiCOM.Form)

                                    oItem = DirectCast(oApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oItems), SAPbobsCOM.Items)

                                    'oForm.Freeze(True)

                                    oMatrix = oForm.Items.Item("0_U_G").Specific

                                    For index As Integer = 1 To oMatrix.VisualRowCount

                                        oMatrix.Columns.Item("#").Cells.Item(index).Specific.Value = 1

                                        oMatrix.Columns.Item("#").Editable = False

                                    Next

                                    'oForm.Freeze(False)

                                    flag = 1

                                End If

                        End Select

                End Select

            Catch ex As Exception

            Finally

            End Try

        End Sub

When Form Opened , The Row Number displayed. But when i clicked Header of Matrix , The Value was removed.

Accepted Solutions (0)

Answers (1)

Answers (1)

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Lakshmi,

Can you try this and let us know the results:

private void SetRowNumber()

        {

            SAPbouiCOM.Matrix oMatrix = (SAPbouiCOM.Matrix)m_SBO_Form.Items.Item("Matrix").Specific;

            try

            {

                if (oMatrix.VisualRowCount > 0)

                {

                    oMatrix.FlushToDataSource();

                    int count = _dBDataSourceChild.Size;

                    for (int i = 0; i <= count-1; i++)

                    {

                        this.m_SBO_Form.DataSources.DBDataSources.Item("@TableName").SetValue("U_LineNum", i, (i + 1).ToString());

                    }

                    oMatrix.LoadFromDataSource();

                }

            }

            catch

            {

                throw;

            }

        }

Please change the code as per your need.

Kind regards,

ANKIT CHAUHAN

SAP Business One Global Support

Former Member
0 Kudos

Hi ,

Thanks for your Code.But your code describe based  on User Defined Field.But Without User Defined Field ,How to Add Row Number in Matrix.