cancel
Showing results for 
Search instead for 
Did you mean: 

Delete matrix row ... help me !!! Urgent !!!

Former Member
0 Kudos

Hi gurus,

I have a form with a matrix, in the matrix have some rows. I choose a row in matrix, and press delete button. Pls tell me how to get index number of selected row in matrix to delete. Or give to me code to do that is the greatest :). Thanks !

I use SBO 2005A, VB.net to develop.

Accepted Solutions (0)

Answers (1)

Answers (1)

AdKerremans
Active Contributor
0 Kudos

Hi andy,

the method getNextSelectedRow of the matrix object gives you the selected row.

Regards

Ad

Former Member
0 Kudos

Hi Ad,

Thank for yr help, but u see this code i did right or wrong, nothing happen.

If (pVal.ItemUID = "Del") And (pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED) Then

oMatrix.DeleteRow(oMatrix.GetNextSelectedRow())

End If

The first column in the matrix is grey, when I click on a row on that column, nothing happen. I want, when click on, it's highlight selected row. And when add row, the automatic number add increase in the first columns. Tell me how to do. Thanks!

former_member184566
Active Contributor
0 Kudos

Hi Andy,

To highlisgt the row you must use something like, this should work in your item event below.

Dim omatrix As SAPbouiCOM.Matrix

omatrix = SBO_Application.Forms.Item("FormID").Items.Item("ItemId").Specific

omatrix.SelectRow(pVal.Row, True, False)

The tru and false are to specify "Select as boolean" and "multiselect as boolean".

Then to set the column value you must do something along the lines.

'declare variables

Dim oEdit As SAPbouiCOM.EditText

Dim oMatrix As SAPbouiCOM.Matrix

Dim oColumn As SAPbouiCOM.Column

Dim oColumns As SAPbouiCOM.Columns

oMatrix = SBO_Application.Forms.Item("MetReadForm").Items.Item("MeterMat").Specific

oMatrix.Clear()

'add a datasource

oForm.DataSources.UserDataSources.Add("#D", SAPbouiCOM.BoDataType.dt_SHORT_TEXT, 20)

oColumn = oColumns.Item("#")

oColumn.DataBind.SetBound(True, "", "#D")

'assign the value

oEdit = oColumns.Item("#").Cells.Item(i).Specific

oEdit.Value = i

Hope this helps

former_member184566
Active Contributor
0 Kudos

Hi,

I forgot to initialize the one thing of the columns "oColumns = oMatrix.Columns"

So it should all be then

oMatrix = SBO_Application.Forms.Item("MetReadForm").Items.Item("MeterMat").Specific

oColumns = oMatrix.Columns

oMatrix.Clear()

Hope it helps

AdKerremans
Active Contributor
0 Kudos

Hi Andy,

Did you set omatrix.SelectionMode = SAPBouiCOM.BoMatrixSelect.ms_Single

Regards,

Ad

Former Member
0 Kudos

Thanks Louis,

Adding auto number, I did. But to highlight selected row, it's nothing happen when I click. Pls to see my code, and tell me what it's wrong or ...

<b>

    Private Sub SBO_Application_ItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.ItemEvent
'// Select row                
               If (pVal.ItemUID = "matrix") And (pVal.ColUID = "#") And (pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED) Then
                        oMatrix.SelectRow(pVal.Row, True, False)
                End If
'// Delete row
                If (pVal.ItemUID = "Del") And (pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED) Then
                    Try
                        oMatrix.SelectionMode = SAPbouiCOM.BoMatrixSelect.ms_Single
                        oMatrix.DeleteRow(oMatrix.GetNextSelectedRow())
                    Catch ex As Exception
                        SBO_Application.MessageBox(ex.ToString)
                    End Try
                End If
    End Sub

</b>

former_member184566
Active Contributor
0 Kudos

Hi Andy,

It should work the way you are doing, i used this exact syntax

If (pVal.ItemUID = "Mat") And (pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED) Then

Dim omatrix As SAPbouiCOM.Matrix

omatrix = SBO_Application.Forms.Item("Choose").Items.Item("Mat").Specific

omatrix.SelectRow(pVal.Row, True, False)

End If

But your's should work. I see you have no try blocks/exception handling. Please put them in and see what the errors are.....it could be something silly like your matrix uid. so write the following if using vb.

try

If (pVal.ItemUID = "Mat") And (pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED) Then

Dim omatrix As SAPbouiCOM.Matrix

omatrix = SBO_Application.Forms.Item("Choose").Items.Item("Mat").Specific

omatrix.SelectRow(pVal.Row, True, False)

End If

catch ex as exception

msgbox(ex.message)

end try

let me know if it works.

former_member184566
Active Contributor
0 Kudos

Hi Andy,

I also realised you said you are on 2005. This code works in 2004. But i do know that when i tested 2005 on my machine it actually gave an error with this in my add ons. I didn't check (debug) fully as i had to go back to 2004, but it was definatly something to do with the row highlight. I garuantee you'll get an error when you put an exception block around the part that has "omatrix.SelectRow(pVal.Row, True, False)". So check that the object hasn't changed and if it's patch related. Also make sure you have 2005 sdk and DI API/UI API in your program.

Hope this helps

Former Member
0 Kudos

Thanks so much, but it also nothing to happen. It's just selected when I double click, but it also open row detail. When I close detail window, that row also lost highlight(unselected). And you see code for delete button (I wrote before message) help me, how to get index of selected row, that code can't delete the row i want.

former_member184566
Active Contributor
0 Kudos

Andy,

Are you using a system document? You can not change this if it is a system document like AR Invoice. But in 2004 if you click on the row in the matrix it automatically highlights it in the system document. No development needed.

So please let me know if it's your own matrix? Then if you got the highlight of the row correct on one click? Once that is working then the value should be easy. Does the # column indent when you select it if it's your own matrix?

former_member184566
Active Contributor
0 Kudos

Also put a break point inside that try catch block to make sure that it is catching the correct event. Might have wrong id somewhere and never does the actual event.

former_member184566
Active Contributor
0 Kudos

Andy,

take "oMatrix.SelectionMode = SAPbouiCOM.BoMatrixSelect.ms_Single" out, you already stipulated it in omatrix.SelectRow(pVal.Row, True, False)....the false was for a multiselect. Because you have selected then reset it with the second event....thats maybe why you are not seeing it. If you still want to use that line put it before omatrix.SelectRow(pVal.Row, True, False).

Hope this is the problem

Former Member
0 Kudos

Hi Louis,

Matrix is my owner matrix,I try to catched event, but pval.colUID have never catch "#" column.

If (pVal.ItemUID="matrix") And (pVal.ColUID = "#") And (pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED) Then
                        oMatrix.SelectRow(pVal.Row, True, False)
End if.

pVal.Row is right,it's always wrong at ' (pVal.ColUID = "#") '

barend_morkel2
Active Contributor
0 Kudos

Hi Andy,

The ColUID for col '#' is 0. Thus use <b>pVal.ColUID = "0"</b>.

  1. is the Title (and/or the Description) for the line number column.

Former Member
0 Kudos

Hi Barend,

I knew yr mind and I do right. But when I catch error, it's " <i>Matrix - selection is not supported for this items</i> ". How to solve ??? Help me, thanks. This's my code

If (pVal.ItemUID = "mat") then
   If (pVal.ColUID = "#") And (pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED) Then
    Try
        oMatrix.SelectRow(pVal.Row, True, False)
    Catch ex As Exception
        SBO_Application.MessageBox(ex.ToString)
    End Try
   End If
End If