oForm.DataSources.UserDataSources.Add("FolderDS", SAPbouiCOM.BoDataType.dt_SHORT_TEXT, 1)'生成一个Folder绑定的UserDatasource
'// Set the form properties
oForm.Title = "生产订单分析调度"
oForm.Left = 320
oForm.ClientWidth = 680
oForm.Top = 60
oForm.ClientHeight = 540
oItem = oForm.Items.Add("Add_B", SAPbouiCOM.BoFormItemTypes.it_BUTTON) '新增按钮
oItem.Left = 60
oItem.Width = 40
oItem.Top = 510
oItem.Height = 19
oButton = oItem.Specific
oButton.Caption = "新增"
'表头信息//**********************************************************************************************************
'//添加调用单据编码
oItem = oForm.Items.Add("PdCCode_C", SAPbouiCOM.BoFormItemTypes.it_COMBO_BOX)
oItem.Left = 100
oItem.Width = 65
oItem.Top = 30
oItem.Height = 14
oComboBox = oItem.Specific
oItem = oForm.Items.Add("BState_L", SAPbouiCOM.BoFormItemTypes.it_STATIC)
oItem.Left = 220
oItem.Width = 65
oItem.Top = 98
oItem.Height = 14
oItem.LinkTo = "BState_C"
oStaticText = oItem.Specific
oStaticText.Caption = "状态"
'表头信息//**********************************************************************************************************
' Folder和Folder所在矩形框//***********************************************************************************
oItem = oForm.Items.Add("Rect1", SAPbouiCOM.BoFormItemTypes.it_RECTANGLE)
oItem.Left = 20
oItem.Width = 640
oItem.Top = 140
oItem.Height = 360
For i = 1 To 3
oItem = oForm.Items.Add("Folder" & i, SAPbouiCOM.BoFormItemTypes.it_FOLDER)
oItem.Left = (i - 1) * 100 + 20
oItem.Width = 100
oItem.Top = 140
oItem.Height = 360
oItem.FromPane = 0
oItem.ToPane = 0
oFolder = oItem.Specific
oFolder.DataBind.SetBound(True, "", "FolderDS") '此处不可缺少,把Foleder绑定与Datasource
If (i = 1) Then
'// set the caption
oFolder.Caption = "订单"
End If
If (i = 2) Then
'// set the caption
oFolder.Caption = "分解单"
End If
If (i = 3) Then
'// set the caption
oFolder.Caption = "生产单"
End If
If i = 1 Then
oFolder.Select()
Else
oFolder.GroupWith(("Folder" & i - 1))'把Folder组合,此句不可缺,否则,Folder将被RectAngle覆盖,在窗口不显示,虽然Folder的Pressed事件仍可用
End If
Next
'Folder和Folder所在矩形框//***********************************************************************************
'调用单的Matrix//*****************************************************************************************
'添加Matrix控件
oItem = oForm.Items.Add("PCMatrix", SAPbouiCOM.BoFormItemTypes.it_MATRIX)
oItem.Left = 30
oItem.Width = 620
oItem.Top = 175
oItem.Height = 310
oItem.FromPane = 1 '把Folder1中的控件建立层次管理
oItem.ToPane = 1
oMatrix = oItem.Specific
oColumns = oMatrix.Columns
oCol = oColumns.Add("#", SAPbouiCOM.BoFormItemTypes.it_EDIT)
oCol.TitleObject.Caption = "#"
oCol.Editable = False
oCol.Width = 16
oCol = oColumns.Add("PCID", SAPbouiCOM.BoFormItemTypes.it_EDIT)
oCol.TitleObject.Caption = "序号"
oCol.Editable = False
oCol.Width = 30
oCol.DataBind.SetBound(True, "", "Code") '绑定自增字段
oMatrix.AutoResizeColumns()
oMatrix.AddRow()
'调用单的Matrix//*****************************************************************************************
'分解单的Matrix//*****************************************************************************************
'添加Matrix控件
oItem = oForm.Items.Add("PAMatrix", SAPbouiCOM.BoFormItemTypes.it_MATRIX)
oItem.Left = 30
oItem.Width = 620
oItem.Top = 175
oItem.Height = 310
oItem.FromPane = 2 '把Folder2中的控件建立层次管理
oItem.ToPane = 2
oMatrix = oItem.Specific
oColumns = oMatrix.Columns
oCol = oColumns.Add("#", SAPbouiCOM.BoFormItemTypes.it_EDIT)
oCol.TitleObject.Caption = "#"
oCol.Editable = False
oCol.Width = 16
oCol = oColumns.Add("PAID", SAPbouiCOM.BoFormItemTypes.it_EDIT)
oCol.TitleObject.Caption = "序号"
oCol.Editable = False
oCol.Width = 30
oCol.DataBind.SetBound(True, "", "ACode") '绑定自增字段
oMatrix.AutoResizeColumns()
oMatrix.AddRow()
'分解单的Matrix//*****************************************************************************************
'生产单的Matrix//*****************************************************************************************
'添加Matrix控件
oItem = oForm.Items.Add("APMatrix", SAPbouiCOM.BoFormItemTypes.it_MATRIX)
oItem.Left = 30
oItem.Width = 620
oItem.Top = 175
oItem.Height = 320
oItem.FromPane = 3'把Folder3中的控件建立层次管理
oItem.ToPane = 3
oMatrix = oItem.Specific
oColumns = oMatrix.Columns
oCol = oColumns.Add("#", SAPbouiCOM.BoFormItemTypes.it_EDIT)
oCol.TitleObject.Caption = "#"
oCol.Editable = False
oCol.Width = 16
oCol = oColumns.Add("PAID", SAPbouiCOM.BoFormItemTypes.it_EDIT)
oCol.TitleObject.Caption = "序号"
oCol.Editable = False
oCol.Width = 30
oCol.DataBind.SetBound(True, "", "APCode") '绑定自增字段
oMatrix.AutoResizeColumns()
oMatrix.AddRow()
'生产订单工序分解单的Matrix//*****************************************************************************************
oForm.Visible = True
If (MenuString = "OWPAna") Then '分解单菜单
oFolder = oForm.Items.Item("Folder1").Specific
oFolder.Select()
oForm.PaneLevel = 1 '分层显示,显示层次1
End If
If (MenuString = "Orduction") Then
oForm.Items.Item("Folder3").Specific.Select()
oForm.PaneLevel = 3 '分层显示,显示层次3
End If
2、Folder关联事件的触发
Public Sub SBO_Application_ItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.ItemEvent
'窗口操作
If ((pVal.FormUID = "SBOdCall") And (pVal.BeforeAction = False)) Then '事件发生在路线窗口
oForm = SBO_Application.Forms.Item(FormUID)
Select Case pVal.EventType
Case SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED
'Case et_ITEM_PRESSED 单击folder事件
If (pVal.ItemUID = "Folder1") Then
oForm.PaneLevel = 1
End If
If (pVal.ItemUID = "Folder2") Then
oForm.PaneLevel = 2
End If
If (pVal.ItemUID = "Folder3") Then
oForm.PaneLevel = 3
End If
Case SAPbouiCOM.BoEventTypes.et_FORM_CLOSE
oForm.PaneLevel = 0
System.Windows.Forms.Application.Exit()
End Select
End If
End Sub
注意事项:
在Folder使用中
1、oForm.DataSources.UserDataSources.Add("FolderDS", SAPbouiCOM.BoDataType.dt_SHORT_TEXT, 1)
oFolder.DataBind.SetBound(True, "", "FolderDS")
这两条语句不可缺,否则,Folder的Press事件发生后,不能触发Folder的Select事件,也就是Folder不能被选中
2、如果Folder和RectAngle组合使用,
If i = 1 Then
oFolder.Select()
Else
oFolder.GroupWith(("Folder" & i - 1))
End If
此代码不可缺,否则Folder将被RectAngle覆盖,在窗口显示不出来
3、Folder的Press事件发生后,不再需要加上oFolder.Select()语句,被单击的Folder将被自动选择。