add textbox mask for integer indexes

This commit is contained in:
Jonathan Jenne 2020-05-18 11:26:25 +02:00
parent a00cc1a39e
commit 7dfa88ef0d
2 changed files with 29 additions and 22 deletions

View File

@ -2,6 +2,7 @@
Imports Oracle.ManagedDataAccess.Client Imports Oracle.ManagedDataAccess.Client
Imports DigitalData.Controls.LookupGrid Imports DigitalData.Controls.LookupGrid
Public Class ClassControls Public Class ClassControls
Private Property Form As frmIndex Private Property Form As frmIndex
Private Property Panel As Panel Private Property Panel As Panel
@ -49,7 +50,7 @@ Public Class ClassControls
Return chk Return chk
Catch ex As Exception Catch ex As Exception
LOGGER.Info("Unhandled Exception in AddCheckBox: " & ex.Message) LOGGER.Info("Unhandled Exception in AddCheckBox: " & ex.Message)
LOGGER.Error(ex.message) LOGGER.Error(ex.Message)
Return Nothing Return Nothing
End Try End Try
End Function End Function
@ -112,7 +113,7 @@ Public Class ClassControls
Return oControl Return oControl
Catch ex As Exception Catch ex As Exception
LOGGER.Info(" - Unvorhergesehener Unexpected error in AddVorschlag_ComboBox - Indexname: " & indexname & " - Fehler: " & vbNewLine & ex.Message) LOGGER.Info(" - Unvorhergesehener Unexpected error in AddVorschlag_ComboBox - Indexname: " & indexname & " - Fehler: " & vbNewLine & ex.Message)
LOGGER.Error(ex.message) LOGGER.Error(ex.Message)
MsgBox(ex.Message, MsgBoxStyle.Critical, "Unvorhergesehener Unexpected error in AddVorschlag_ComboBox:") MsgBox(ex.Message, MsgBoxStyle.Critical, "Unvorhergesehener Unexpected error in AddVorschlag_ComboBox:")
Return Nothing Return Nothing
End Try End Try
@ -290,54 +291,60 @@ Public Class ClassControls
End If End If
Catch ex As Exception Catch ex As Exception
LOGGER.Info(" - Unvorhergesehener Unexpected error in Renew_ComboboxResults - Fehler: " & vbNewLine & ex.Message) LOGGER.Info(" - Unvorhergesehener Unexpected error in Renew_ComboboxResults - Fehler: " & vbNewLine & ex.Message)
LOGGER.Error(ex.message) LOGGER.Error(ex.Message)
MsgBox(ex.Message, MsgBoxStyle.Critical, "Unvorhergesehener Unexpected error in Renew_ComboboxResults:") MsgBox(ex.Message, MsgBoxStyle.Critical, "Unvorhergesehener Unexpected error in Renew_ComboboxResults:")
End Try End Try
End Sub End Sub
Public Function AddTextBox(indexname As String, y As Integer, text As String, DataType As String) As TextBox Public Function AddTextBox(indexname As String, y As Integer, text As String, DataType As String) As DevExpress.XtraEditors.TextEdit
Dim txt As New TextBox With { Dim oEdit As New DevExpress.XtraEditors.TextEdit With {
.Name = "txt" & indexname, .Name = "txt" & indexname,
.Size = New Size(260, 27), .Size = New Size(260, 27),
.Location = New Point(11, y), .Location = New Point(11, y),
.Tag = New ControlMeta() With { .Tag = New ControlMeta() With {
.IndexName = indexname, .IndexName = indexname,
.IndexType = DataType .IndexType = DataType
} }
} }
If text <> "" Then Select Case DataType
txt.Text = text Case "INTEGER"
txt.Size = New Size(CInt(text.Length * 15), 27) oEdit.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric
txt.SelectAll() End Select
If text IsNot Nothing Then
oEdit.Text = text
oEdit.SelectAll()
End If End If
AddHandler txt.GotFocus, AddressOf OnTextBoxFocus
AddHandler txt.LostFocus, AddressOf OnTextBoxLostFocus AddHandler oEdit.GotFocus, AddressOf OnTextBoxFocus
AddHandler txt.KeyUp, AddressOf OnTextBoxKeyUp AddHandler oEdit.LostFocus, AddressOf OnTextBoxLostFocus
AddHandler txt.TextChanged, AddressOf OnTextBoxTextChanged AddHandler oEdit.KeyUp, AddressOf OnTextBoxKeyUp
Return txt AddHandler oEdit.TextChanged, AddressOf OnTextBoxTextChanged
Return oEdit
End Function End Function
Public Sub OnTextBoxFocus(sender As System.Object, e As System.EventArgs) Public Sub OnTextBoxFocus(sender As System.Object, e As System.EventArgs)
Dim oTextbox As TextBox = sender Dim oTextbox As DevExpress.XtraEditors.TextEdit = sender
oTextbox.BackColor = Color.Lime oTextbox.BackColor = Color.Lime
oTextbox.SelectAll() oTextbox.SelectAll()
End Sub End Sub
Public Sub OnTextBoxTextChanged(sender As System.Object, e As System.EventArgs) Public Sub OnTextBoxTextChanged(sender As System.Object, e As System.EventArgs)
Dim oTextbox As TextBox = sender Dim oTextbox As DevExpress.XtraEditors.TextEdit = sender
Using oGraphics As Graphics = oTextbox.CreateGraphics() Using oGraphics As Graphics = oTextbox.CreateGraphics()
oTextbox.Width = oGraphics.MeasureString(oTextbox.Text, oTextbox.Font).Width + 15 oTextbox.Width = oGraphics.MeasureString(oTextbox.Text, oTextbox.Font).Width + 15
End Using End Using
End Sub End Sub
Public Sub OnTextBoxLostFocus(sender As System.Object, e As System.EventArgs) Public Sub OnTextBoxLostFocus(sender As System.Object, e As System.EventArgs)
Dim oTextbox As TextBox = sender Dim oTextbox As DevExpress.XtraEditors.TextEdit = sender
oTextbox.BackColor = Color.White oTextbox.BackColor = Color.White
End Sub End Sub
Public Sub OnTextBoxKeyUp(sender As System.Object, e As System.Windows.Forms.KeyEventArgs) Public Sub OnTextBoxKeyUp(sender As System.Object, e As System.Windows.Forms.KeyEventArgs)
Dim oTextbox As TextBox = sender Dim oTextbox As DevExpress.XtraEditors.TextEdit = sender
If oTextbox.Text = String.Empty Then If oTextbox.Text = String.Empty Then
Exit Sub Exit Sub
@ -445,7 +452,7 @@ Public Class ClassControls
LOGGER.Warn("Error in SQL Command: {0}", SqlCommand) LOGGER.Warn("Error in SQL Command: {0}", SqlCommand)
End If End If
If TypeOf oFoundControl Is TextBox Then If TypeOf oFoundControl Is DevExpress.XtraEditors.TextEdit Then
If oDatatable.Rows.Count > 0 Then If oDatatable.Rows.Count > 0 Then
Dim oFirstRow As DataRow = oDatatable.Rows.Item(0) Dim oFirstRow As DataRow = oDatatable.Rows.Item(0)
@ -453,7 +460,7 @@ Public Class ClassControls
Dim oValue = oFirstRow.Item(0).ToString() Dim oValue = oFirstRow.Item(0).ToString()
LOGGER.Debug("Setting Value for control [{0}]: [{1}]", oFoundControl.Name, oValue) LOGGER.Debug("Setting Value for control [{0}]: [{1}]", oFoundControl.Name, oValue)
DirectCast(oFoundControl, TextBox).Text = oValue DirectCast(oFoundControl, DevExpress.XtraEditors.TextEdit).Text = oValue
End If End If
End If End If
ElseIf TypeOf oFoundControl Is LookupControl2 Then ElseIf TypeOf oFoundControl Is LookupControl2 Then

View File

@ -281,7 +281,7 @@ Public Class frmIndex
For Each oControl As Control In Me.pnlIndex.Controls For Each oControl As Control In Me.pnlIndex.Controls
' MsgBox(ctrl.Name) ' MsgBox(ctrl.Name)
If oControl.Name.StartsWith("txt") Then If oControl.Name.StartsWith("txt") Then
Dim box As TextBox = oControl Dim box As DevExpress.XtraEditors.TextEdit = oControl
If box.Text = "" Then If box.Text = "" Then
Dim optional_index As Boolean = ClassDatabase.Execute_Scalar("SELECT OPTIONAL FROM TBDD_INDEX_MAN WHERE DOK_ID = " & dokartid & " AND NAME = '" & Replace(box.Name, "txt", "") & "'", MyConnectionString, True) Dim optional_index As Boolean = ClassDatabase.Execute_Scalar("SELECT OPTIONAL FROM TBDD_INDEX_MAN WHERE DOK_ID = " & dokartid & " AND NAME = '" & Replace(box.Name, "txt", "") & "'", MyConnectionString, True)
If optional_index = False Then If optional_index = False Then