SBO二次开发中点击Matrix第一行的排序功能代码

[复制链接]
查看11 | 回复0 | 2010-12-20 16:42:34 | 显示全部楼层 |阅读模式
看有人问到了,就把之前写的代码拿出来跟大家分享下。
事件响应写在ItemEvent中,鼠标双击事件。
Public Sub SortMatrix(ByVal pval As SAPbouiCOM.ItemEvent)

Dim DT As DataTable

Dim DTCol As System.Data.DataColumn

Dim DTRow As System.Data.DataRow

Dim DTRowV As System.Data.DataRowView

Dim oForm As SAPbouiCOM.Form

Dim oDBDS As SAPbouiCOM.DBDataSource

Dim oItem As SAPbouiCOM.Item

Dim oMatrix As SAPbouiCOM.Matrix

Dim oCol As SAPbouiCOM.Column

Dim sKeyColField As String '排序的字段绑定的Datasource字段名

Dim iRow As Integer

Dim iLineId As Integer

Dim iDSIndex As Integer

Dim objCompareValue_1 As Object

Dim objCompareValue_2 As Object

Dim dtDataType As System.Type

Try

oForm = SBOApp.Forms.Item(pval.FormUID)

oItem = oForm.Items.Item(pval.ItemUID)

If oItem.TypeSAPbouiCOM.BoFormItemTypes.it_MATRIX Then Exit Sub

DT = New System.Data.DataTable

DTCol = New System.Data.DataColumn

oMatrix = oForm.Items.Item(pval.ItemUID).Specific

If oMatrix.RowCountobjCompareValue_2 Then '原来是降序排列

DT.DefaultView.Sort = sKeyColField

ElseIf objCompareValue_1
''' 根据BO的数据类型获取系统数据类型
'''
'''
'''
'''
Public Function GetSystemDataTypeBySBODataType(ByVal DataType As SAPbouiCOM.BoFieldsType) As System.Type

Try

Select Case DataType

Case SAPbouiCOM.BoFieldsType.ft_AlphaNumeric

Return System.Type.GetType("System.String")

Case SAPbouiCOM.BoFieldsType.ft_Date

Return System.Type.GetType("System.String")

Case SAPbouiCOM.BoFieldsType.ft_Float

Return System.Type.GetType("System.Single")

Case SAPbouiCOM.BoFieldsType.ft_Integer

Return System.Type.GetType("System.Int32")

Case Else

Return System.Type.GetType("System.String")

End Select

Catch ex As Exception

Return System.Type.GetType("System.String")

End Try
End Function
'''
''' 得到Matrix单元格的值
'''
''' 列
''' 行
'''
'''
Public Function GetMatrixCellValue(ByVal Column As SAPbouiCOM.Column, ByVal Row As Integer) As Object

Dim edt As SAPbouiCOM.EditText

Dim chk As SAPbouiCOM.CheckBox

Dim cmb As SAPbouiCOM.ComboBox

Dim oObject As Object

Try

Select Case Column.Type

Case SAPbouiCOM.BoFormItemTypes.it_CHECK_BOX

chk = Column.Cells.Item(Row).Specific

If chk.Checked Then Return "Y" Else Return "N"

Case SAPbouiCOM.BoFormItemTypes.it_EDIT, SAPbouiCOM.BoFormItemTypes.it_LINKED_BUTTON

edt = Column.Cells.Item(Row).Specific

Return edt.Value

Case SAPbouiCOM.BoFormItemTypes.it_COMBO_BOX

cmb = Column.Cells.Item(Row).Specific

Try

oObject = cmb.Selected.Value

Catch ex As Exception

End Try

Return oObject

End Select

Catch ex As Exception

Throw New Exception

End Try
End Function
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行