下面的代码不能用 LINQ/func 委托完成(并且做得更好)吗?我对 LINQ/func 相当陌生。我正在遍历表单上的所有控件以查找所有 FlowLayoutPanel(它们嵌入选项卡和拆分容器中)并将控件索引信息保存到应用程序设置中,以便在加载时调用它。我的应用程序允许用户通过拖放重新定位他们的 GUI/控件。*注意,ServicingLayout
是我自己的可序列化类,其中包含我需要恢复用户偏好的信息。
Private Sub SaveFlow(ByVal F As FlowLayoutPanel) Handles Me.FoundFlow
For Each C As Control In F.Controls
My.Settings.ServicingLayout.AddControl(F.Name, C.Name, F.Controls.GetChildIndex(C))
Next
End Sub
Private Event FoundFlow(ByVal F As FlowLayoutPanel)
Private Sub SaveFlowLayouts(ByVal CC As Object)
For Each C As Control In CC
If TypeOf C Is FlowLayoutPanel Then RaiseEvent FoundFlow(C)
If C.Controls.Count > 0 Then SaveFlowLayouts(C.Controls)
Next
End Sub
谢谢!