You are currently viewing How to Select a row in System Matrix(SAPbouiCOM.Matrix) in SAP Busines One?
SAP Business One

How to Select a row in System Matrix(SAPbouiCOM.Matrix) in SAP Busines One?

4.5
(2)

You can call SelectRow() Method of System Matrix to select a particular row in System Matrix.

Please check the following example.

public void SBO_Application_ItemEvent(string FormUID, ref SAPbouiCOM.ItemEvent pVal, out bool BubbleEvent)
  {
    if ((pVal.ItemUID == "Matrix1") & (pVal.EventType != BoEventTypes.et_CLICK))
        {
                        try
                        {
                            SAPbouiCOM.Form oForm1 = SBO_Application.Forms.ActiveForm;
                            Item oItemmatrix = oForm1.Items.Item("Matrix1");
                            Matrix oMatrix = ((SAPbouiCOM.Matrix)(oItemmatrix.Specific));
                            oMatrix.SelectionMode = BoMatrixSelect.ms_Auto;
                            oMatrix.SelectRow(pVal.Row, true, false);
                        }
                        catch(Exception ex) { }
                        
        }
  }

Please Note: before calling oMatrix.SelectRow() method we should set selection mode to auto. like below

oMatrix.SelectionMode = SAPbouiCOM.BoMatrixSelect.ms_Auto;

oMatrix.SelectRow(pVal.Row, true, false);

To get the column value you can code like below

public void SBO_Application_ItemEvent(string FormUID, ref SAPbouiCOM.ItemEvent pVal, out bool BubbleEvent)
  {
    if ((pVal.ItemUID == "Matrix1") & (pVal.EventType != BoEventTypes.et_CLICK))
        {
                        try
                        {
                            SAPbouiCOM.Form oForm1 = SBO_Application.Forms.ActiveForm;
                            Item oItemmatrix = oForm1.Items.Item("Matrix1");
                            Matrix oMatrix = ((SAPbouiCOM.Matrix)(oItemmatrix.Specific));
                            string COLVALUE = Convert.ToInt32(((SAPbouiCOM.EditText)oMatrix.Columns.Item("COLID").Cells.Item(pVal.Row).Specific).Value.ToString());
                            oMatrix.SelectionMode = BoMatrixSelect.ms_Auto;
                            oMatrix.SelectRow(pVal.Row, true, false);
                        }
                        catch(Exception ex) { }
                        
        }
  }

Please Note: Replace COLID with your ColumnName.

How useful was this post?

Click on a star to rate it!

Average rating 4.5 / 5. Vote count: 2

No votes so far! Be the first to rate this post.

As you found this post useful...

Share this post on social media!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?