Vertragsverwaltung-Klassenbibliothek  

FrmReportSelect.GetControl -Methode

Sucht in den Base-Controls sämtliche Controls mit dem Namen in "Key" (Wildcards * möglich) und listet die gefundnen Controls in der Liste L zur weiteren Bearbeitung

[Visual Basic]
Private Function GetControl( _ 
ByVal BaseControl As Control, _ 
ByVal Key As String, _ 
ByRef L As List(Of Control), _ 
Optional ByVal ReturnAtFirstElement As Boolean = False _ 
) As Boolean

Parameter

BaseControl
Base-Contrlo (z.B. aktuelles Formular
Key
Schlüssel welcher gesucht werden soll
L
Liste der gefundenen Objekte
ReturnAtFirstElement
Optional. Der Standardwert ist False.

Rückgabewert

True wenn eines oder mehr Controls gefunden wurden, false wenn kein Control gefunden wurde.

Quellcode

[Visual Basic]
    Private Function GetControl(ByVal BaseControl As Control, ByVal Key As String, ByRef L As List(Of Control), Optional ByVal ReturnAtFirstElement As Boolean = False) As Boolean 
If L Is Nothing Then L = New List(Of Control) 
Dim Gut As Boolean 
Dim ReturnFlag As Boolean = False 
If Key IsNot Nothing Then Key = Key.ToLower 
 
If BaseControl.HasChildren = True Then 
For Each ctl As Control In BaseControl.Controls 
Gut = False 
If Key Is Nothing Then 
Gut = True 
Else 
If ctl.Name.Length >= Key.Length Then 
Key = Key.ToLower 
If Key.StartsWith("*") Then 
If Key.Substring(1) = ctl.Name.ToLower.Substring(ctl.Name.Length - (Key.Length - 1), Key.Length - 1) Then Gut = True 
ElseIf Key.EndsWith("*") Then 
If Key.Substring(0, Key.Length - 1) = ctl.Name.ToLower.Substring(0, Key.Length - 1) Then Gut = True 
Else 
If Key = ctl.Name.ToLower Then Gut = True 
End If 
End If 
End If 
 
If Gut = True Then 
L.Add(ctl) 
If ReturnAtFirstElement = True Then ReturnFlag = True 
End If 
If ReturnFlag = False Then 
Call GetControl(ctl, Key, L) 
End If 
Next 
End If 
 
If L.Count - 1 > -1 Then 
Return True 
Else 
Return False 
End If 
End Function

Forderungen

Plattformen: Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

Siehe auch

FrmReportSelect