对上下文敏感的帮助添加到现有的Windows好办法窗体应用程序?
-
19-09-2019 - |
题
我不得不数据库驱动工具提示添加到现有WinForms应用程序,大的。 C#和.NET 3.5
我想避免不必删除新的控制这一点,和用户必须能够编辑的帮助工具提示。
我最好的猜测是包装在一个新的类型,包含新的属性的现有的控制,这样我可以分配像“FieldHelpName”一个新的属性,并且可以使用该管理模块中,以便用户可以清楚地识别字段。我会分配一个ScreenID给每个窗体和每个FieldHelpName记录将被链接到一个ScreenID。在应用程序启动,通过其ScreenID加载所有帮助内容,并且在形式负载,过滤器和使用反射,最有可能添加相应的工具提示。
我要找的建议,关于如何做这个过程最好还是知道是否有关于如何做到这一点......因此任何帮助是非常感谢的最佳做法。感谢。
解决方案 2
结束了创建用于配置一个数据库表和为每一行指定控制名称,然后循环屏幕控制递归如果所述电流控制名称数据库记录的控制名匹配添加工具提示。
其他提示
为什么进入这样的长度?
您可以完成同样的事情用简单的东西:
Private _ToolTipList As New List(Of ToolTip)
<Extension()> _
Public Function CreateForm(ByVal formType As Type) As Form
If (formType Is Nothing) Then
Throw New ArgumentNullException("formType")
End If
If (Not GetType(Form).IsAssignableFrom(formType)) Then
Throw New InvalidOperationException _
(String.Format("The type '{0}' is not a form.", formType.FullName))
End If
Dim ctor = formType.GetConstructor(New Type() {})
If (ctor Is Nothing) Then
Throw New InvalidOperationException _
(String.Format _
("The type '{0}' does not have a public default constructor.", _
formType.FullName))
End If
Dim frm As Form = ctor.Invoke(New Object() {})
Dim toolTip As New ToolTip(New Container())
LoadToolTipData(toolTip, frm)
_ToolTipList.Add(toolTip)
Return frm
End Function
Private Sub LoadToolTipData(ByVal toolTip As ToolTip, _
ByVal ctrl As Control, _
Optional ByVal parentHierarchy As String = "")
Dim currentHierarchy = parentHierarchy & "." & ctrl.Name
Dim toolTipText = LoadDataFromDb(currentHierarchy)
If Not String.IsNullOrEmpty(toolTipText) Then
toolTip.SetToolTip(ctrl, toolTipText)
End If
For Each c As Control In ctrl.Controls
LoadToolTipData(toolTip, c, currentHierarchy)
Next
End Sub
Private Function LoadDataFromDb(ByVal key As String) As String
Return String.Empty
End Function
不隶属于 StackOverflow