Hallo Leute,
ich wollte mal fragen ob es möglich ist dies zu vereinfachen..
Die Frage die ich mir stelle ist folgende: "Kann man im Grunde hinterlegen, dass alle Controls, welche die Eigenschaft ".Text" besitzen, mit einer Methode abgedeckt werden?"
Ohne das ich Explizit die Methode kopieren muss, für das jew. Control.
Hoffe ihr versteht was ich meine..
Grüße,
Drahuverar
ich wollte mal fragen ob es möglich ist dies zu vereinfachen..
VB.NET-Quellcode
- Public DisallowedCharacters As String = "ÄÖÜäöüABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
- 'TextBox
- Public Sub CheckForDisallowedCharacters(ByRef TextboxControl As TextBox)
- Dim theText As String = TextboxControl.Text
- Dim Letter As String
- Dim SelectionIndex As Integer = TextboxControl.SelectionStart
- Dim Change As Integer
- For x As Integer = 0 To TextboxControl.Text.Length - 1
- Letter = TextboxControl.Text.Substring(x, 1)
- If DisallowedCharacters.Contains(Letter) Then
- Media.SystemSounds.Beep.Play()
- theText = theText.Replace(Letter, String.Empty)
- Change = 1
- End If
- Next
- TextboxControl.Text = theText
- TextboxControl.Select(SelectionIndex - Change, 0)
- End Sub
- 'ComboBox
- Public Sub CheckForDisallowedCharacters(ByRef ComboBox As ComboBox)
- Dim theText As String = ComboBox.Text
- Dim Letter As String
- Dim SelectionIndex As Integer = ComboBox.SelectionStart
- Dim Change As Integer
- For x As Integer = 0 To ComboBox.Text.Length - 1
- Letter = ComboBox.Text.Substring(x, 1)
- If DisallowedCharacters.Contains(Letter) Then
- Media.SystemSounds.Beep.Play()
- theText = theText.Replace(Letter, String.Empty)
- Change = 1
- End If
- Next
- ComboBox.Text = theText
- ComboBox.Select(SelectionIndex - Change, 0)
- End Sub
Die Frage die ich mir stelle ist folgende: "Kann man im Grunde hinterlegen, dass alle Controls, welche die Eigenschaft ".Text" besitzen, mit einer Methode abgedeckt werden?"
Ohne das ich Explizit die Methode kopieren muss, für das jew. Control.
Hoffe ihr versteht was ich meine..
Grüße,
Drahuverar
Option Strict On!