Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Matrix with textbox.

Dear colleagues,

I have a table with a number, date, description and a text.

I want a form where I can scroll the records in a matrix (or grid) and then see the text belonging to the highlighted record in a textbox below.

How can I do this?

Something with a datasource?

Can someone help me a little?

Kind regards,


Former Member
Former Member replied


More samples you can find in SAP SDK Samples and this forum.

For your example, I used MatrixAndDataSources sample (look COM UI\VB.NET\06.MatrixAndDataSources\2003).

To have form what do you want need adding of some rows of vb code.

1) Open project 06.MatrixAndDataSources\2003 and paste this sub

what create the text field. See comments.

Private Sub AddMyTextField()
  '// we will use the following object to add items to our form
  Dim oItem As SAPbouiCOM.Item
  '// to have space for our field :)... change Width of the Phone field text box from 163 to 80
  oItem = oForm.Items.Item("txtPhone")
  oItem.Width = 80
  '// Adding a Text Edit item "txtMyField"
  oItem = oForm.Items.Add("txtMyField", SAPbouiCOM.BoFormItemTypes.it_EDIT)
  oItem.Left = 428
  oItem.Width = 80
  oItem.Top = 172
  oItem.Height = 14
  '// Matrix: so we set single row selection mode
  oMatrix.SelectionMode = SAPbouiCOM.BoMatrixSelect.ms_Single
End Sub

2) At the last row of CreateFormWithMatrix() sub add row with call to our AddMyTextField() sub

Private Sub CreateFormWithMatrix()
  '// AFTER THIS ROW ...
  ' +++++++++++++++++++++++++++++++++++++
  ' ADD Call to my text field subroutine
  ' +++++++++++++++++++++++++++++++++++++
  Call AddMyTextField()
End Sub

3) Add matrix row selection event catching: in the Sub SBO_Application_ItemEvent(...) add this code:

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

  ' +++++++++++++++++++++++++++++++++++++++++++++++++
  ' +++++++++++++++++++++++++++++++++++++++++++++++++
  If (pVal.FormUID = "UidFrmMatrix") Then
      If ((pVal.ItemUID = "Matrix1") And _
		      (pVal.EventType = SAPbouiCOM.BoEventTypes.et_CLICK) And _
		      (pVal.Before_Action = False)) Then
	  ' So we get value of CardCode cell (column DSCardCode) in the selected row
	  Dim i As Integer = pVal.Row
	  Dim oEdit As SAPbouiCOM.EditText
	  oEdit = oMatrix.Columns.Item("DSCardCode").Cells.Item(i).Specific
	  Dim sValue As String = oEdit.String
	  ' So we set value of txtMyField
	  oEdit = oForm.Items.Item("txtMyField").Specific
	  oEdit.Value = sValue
	  ' So we stop catching events
	  BubbleEvent = False
	  BubbleEvent = True
      End If
  End If

End Sub

Run SAP Client and launch the project.

Hope it help you.

Sierdna S.

0 View this answer in context

Helpful Answer

Not what you were looking for? View more on this topic or Ask a question