cancel
Showing results for 
Search instead for 
Did you mean: 

Matrix with textbox.

Former Member
0 Kudos

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,

John

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

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 ...
  AddMatrixToForm()
  ' +++++++++++++++++++++++++++++++++++++
  ' 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

  ' +++++++++++++++++++++++++++++++++++++++++++++++++
  ' CATCHING SELECT ROW EVENT
  ' +++++++++++++++++++++++++++++++++++++++++++++++++
  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
      Else
	  BubbleEvent = True
      End If
  End If

End Sub

Run SAP Client and launch the project.

Hope it help you.

Sierdna S.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Thank yous for your quick replies.

If we keep getting your answers like this we get very spoiled.

Kind Regards,

John

Nussi
Active Contributor
0 Kudos

Hi John,

simple catch the GOT_FOCUS event from your matrix-cells and copy the

value to the EditText field.

when i understood you correct, that's no big deal

lg David