当用户单击addnewandedit
按钮时,我想为客户实体提供一个“列表和详细信息”应用程序,我想打开一个具有有限字段数的自定义模式屏幕。
在指南中,它说创建一个新的“详细信息”屏幕并将其设置为默认值应该可以做到这一点,但是它不使用自定义屏幕,而是仍然使用自动生成的屏幕。
我尝试使用覆盖按钮,application.showcustomAddClient()
但这会将其作为选项卡而不是像自动生成的模态窗口那样打开。
然后我尝试将其设置customaddclient
为模态窗口,但是现在当我单击时addandeditnew
,我必须单击一个按钮,然后将其作为模态窗口打开,我无法弄清楚为什么它不打开模态窗口直?
我尝试调用,application.showscreen(customaddclient,Enumerable.Empty<object>())
但是语法错误。
如何指定用于自定义模式屏幕的任何帮助addandeditnew
都将非常有帮助。
对于我的自定义Modal Windows,我喜欢使用@YannDuran的Modal Windows Helper类。创建它时,将要添加到的表或查询,自定义模态窗口的名称以及(可选)在模态窗口顶部放置的标题传递给它。该类几乎负责其余的工作,包括正确处理X
按钮。
您的代码将如下所示:
'Declare a Modal Window Helper for use in this screen
Private AddClientHelper As ModalWindowHelper
Private Sub ScreenName_InitializeDataWorkspace(saveChangesTo As System.Collections.Generic.List(Of Microsoft.LightSwitch.IDataService))
'Create Helpers
Me.AddClientHelper = New ModalWindowHelper(Me.qClientTable, "mwAddClient", "Add Client")
End Sub
Private Sub ScreenName_Created()
'Initialize Helpers
Me.AddClientHelper.Initialise()
End Sub
Private Sub qClientTableAddAndEditNew_CanExecute(ByRef result As Boolean)
'Check to see if user is allowed to add an Entity
result = Me.AddClientHelper.CanAdd()
End Sub
Private Sub qClientTableAddAndEditNew_Execute()
'Add a new Entity to the Collection
Me.AddClientHelper.AddEntity()
End Sub
Private Sub qClientTableEditSelected_CanExecute(ByRef result As Boolean)
'Check to see if user is allowed to view an Entity
result = Me.AddClientHelper.CanView()
End Sub
Private Sub qClientTableEditSelected_Execute()
'Open selected Entity for viewing/editing
Me.AddClientHelper.ViewEntity()
End Sub
'Save button on custom Modal Window
Private Sub btnSaveClient_Execute()
'Check for validation errors
If (Me.Details.ValidationResults.HasErrors = False) Then
'Close the modal window
Me.AddClientHelper.DialogOk()
'Save the new Client to the database
Me.Save()
Else
'If validation errors exist,
Dim res As String = ""
'Add each one to a string,
For Each msg In Me.Details.ValidationResults
res = res & msg.Property.DisplayName & ": " & msg.Message & vbCrLf
Next msg
'And display them in a message box
Me.ShowMessageBox(res, "Validation error", MessageBoxOption.Ok)
End If
End Sub
'Cancel button on custom Modal Window
Private Sub btnCancelClient_Execute()
'Cancel the entry, discarding the changes
Me.AddClientHelper.DialogCancel()
End Sub
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句