cancel
Showing results for 
Search instead for 
Did you mean: 

Code Help Add Row

Former Member
0 Kudos

Experts,

For Add row in matrix I have written

Case "AddRow"

Try

Dim omatrix As SAPbouiCOM.Matrix

omatrix = objform.Items.Item("mtx_0").Specific

If omatrix.RowCount > 0 Then

Dim rows As Integer = omatrix.RowCount

For i As Integer = 1 To rows

If omatrix.IsRowSelected(i) = True Then

Dim result As Integer

result = result = SBO_Appln.MessageBox("Do You Want to Add Row", 1, "Yes", "Cancel")

If result = 1 Then

omatrix.AddRow()

objform.Mode = SAPbouiCOM.BoFormMode.fm_UPDATE_MODE

Exit For

End If

End If

Next

End If

Catch ex As Exception

End Try

But it is not working. Please help. And how to have same feel like Std B1 where if we add row anywhere in matrix, it will take the exact row numbers and also we can add row anywhere in between not only for last row

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Try This.......


Try
Dim omatrix As SAPbouiCOM.Matrix
omatrix = objform.Items.Item("mtx_0").Specific
If omatrix.RowCount > 0 Then
Dim rows As Integer = omatrix.RowCount
For i As Integer = 1 To rows
If omatrix.IsRowSelected(i) = True Then
Dim result As Integer
result = SBO_Appln.MessageBox("Do You Want to Add This Row", 1, "Yes", "Cancel")
If result = 1 Then
  omatrix.AddRow(1, pVal.Row + 1)
objform.Mode = SAPbouiCOM.BoFormMode.fm_UPDATE_MODE
Exit For
End If
End If
Next
End If


Thanks

Shafi

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

For Adding a row

Try This.....


case "AddRow"
 omatrix.AddRow(1)

Thanks

Shafi

Former Member
0 Kudos

Try

Dim omatrix As SAPbouiCOM.Matrix

omatrix = objform.Items.Item("mtx_0").Specific

If omatrix.RowCount > 0 Then

Dim rows As Integer = omatrix.RowCount

For i As Integer = 1 To rows

If omatrix.IsRowSelected(i) = True Then

Dim result As Integer

result = SBO_Appln.MessageBox("Do You Want to Delete This Row", 1, "Yes", "Cancel")

If result = 1 Then

omatrix.AddRow()

objform.Mode = SAPbouiCOM.BoFormMode.fm_UPDATE_MODE

Exit For

End If

End If

Next

End If

Catch ex As Exception

End Try

If i use this, then if i select last row and give add row, it is showing the last row's content only. But for add row, in std

only blank row comes. And if i do add row in between (not in last row) or after first row, it adds last tow only copying last row's content

former_member689126
Active Contributor
0 Kudos

Hi

I you want to add row in a particular position you can use

matrix.AddRow(RowCount,position)
  eg ; matrix.AddRow(1, 2)

Regards

Arun

Former Member
0 Kudos

Try

Dim omatrix As SAPbouiCOM.Matrix

omatrix = objform.Items.Item("mtx_0").Specific

If omatrix.RowCount > 0 Then

Dim rows As Integer = omatrix.RowCount

For i As Integer = 1 To rows

If omatrix.IsRowSelected(i) = True Then

Dim result As Integer

result = SBO_Appln.MessageBox("Do You Want to Add This Row", 1, "Yes", "Cancel")

If result = 1 Then

omatrix.AddRow(1, i + 1)

objform.Mode = SAPbouiCOM.BoFormMode.fm_UPDATE_MODE

Exit For

End If

End If

Next

End If

Catch ex As Exception

End Try

this not working properly....

former_member689126
Active Contributor
0 Kudos

Hi

Try

Dim omatrix As SAPbouiCOM.Matrix

omatrix = objform.Items.Item("mtx_0").Specific

If omatrix.RowCount > 0 Then

Dim rows As Integer = omatrix.RowCount

For i As Integer = 1 To rows

If omatrix.IsRowSelected(i) = True Then

Dim result As Integer

result = SBO_Appln.MessageBox("Do You Want to Add This Row", 1, "Yes", "Cancel")

If result = 1 Then

omatrix.AddRow(1, i + 1)

objform.Mode = SAPbouiCOM.BoFormMode.fm_UPDATE_MODE

Exit For

End If

End If

Next

End If

Catch ex As Exception

End Try

Regards

Arun

Former Member
0 Kudos

Try

Dim omatrix As SAPbouiCOM.Matrix

omatrix = objform.Items.Item("mtx_0").Specific

If omatrix.RowCount > 0 Then

Dim rows As Integer = omatrix.RowCount

For i As Integer = 1 To rows

If omatrix.IsRowSelected(i) = True Then

Dim result As Integer

result = SBO_Appln.MessageBox("Do You Want to Add This Row", 1, "Yes", "Cancel")

If result = 1 Then

omatrix.AddRow(1, i)

objform.Mode = SAPbouiCOM.BoFormMode.fm_UPDATE_MODE

Exit For

End If

End If

Next

End If

With objform.DataSources.DBDataSources.Item("@CYCLE")

.Clear()

omatrix.FlushToDataSource()

For iRow As Integer = 0 To omatrix.RowCount - 1

.SetValue("LineId", iRow, (iRow + 1).ToString) 'U_RowNo is the db field binded with your row no column

Next

End With

omatrix.LoadFromDataSource()

Catch ex As Exception

End Try

omatrix.AddRow(1, i) is giving correct value instead of omatrix.AddRow(1, i+1) which is a bit strange anywez...

But blank row is not coming, instead of that last row values coming

Former Member
0 Kudos

How to add blank rows?