Switch from Textbox to DevExpress TextEdit

This commit is contained in:
Jonathan Jenne
2023-05-30 13:33:22 +02:00
parent 37b02ec625
commit 9da71349b2
6 changed files with 186 additions and 82 deletions

View File

@@ -19,6 +19,8 @@ Imports DevExpress.XtraGrid
Imports DevExpress.XtraGrid.Views.Grid
Imports DevExpress.XtraBars
Imports DevExpress.XtraGrid.Columns
Imports DevExpress.XtraEditors
Imports DevExpress.Data
Public Class frmValidator
Private Property Current_Document As DocumentResultList.Document = Nothing
@@ -741,7 +743,7 @@ Public Class frmValidator
End If
Dim oValue
If TypeOf control Is TextBox Then
If TypeOf control Is TextEdit Then
Try
Dim firstRow As DataRow = oDTContent.Rows(0)
@@ -755,7 +757,7 @@ Public Class frmValidator
End Try
ElseIf TypeOf control Is ComboBox Then
Try
Dim oMyComboBox As ComboBox = control
Dim oMyComboBox As Windows.Forms.ComboBox = control
Dim oselectedIndex = oMyComboBox.SelectedIndex
LOGGER.Debug($"oMyComboBox {oMyComboBox.Name} - Saving selected index {oselectedIndex}")
Dim list As New List(Of String)
@@ -898,7 +900,7 @@ Public Class frmValidator
oControlInfo = ClassControlCreator.PREFIX_TEXTBOX & "#" & oControlInfo
LOGGER.Debug($"[{oControlInfo}] - TXT Try to create control...")
Dim txt As TextBox = ClassControlCreator.CreateExistingTextbox(oControlRow, False)
Dim txt As TextEdit = ClassControlCreator.CreateExistingTextbox(oControlRow, False)
AddHandler txt.GotFocus, AddressOf OnTextBoxFocus
AddHandler txt.LostFocus, AddressOf OnTextBoxLostFocus
AddHandler txt.KeyUp, AddressOf OnTextBoxKeyUp
@@ -1177,7 +1179,7 @@ Public Class frmValidator
For Each inctrl As Control In Me.PanelValidatorControl.Controls
Dim Type As String = inctrl.GetType.ToString
Select Case Type
Case "System.Windows.Forms.TextBox"
Case "DevExpress.XtraEditors.TextEdit"
inctrl.Text = ""
Case "System.Windows.Forms.ComboBox"
Dim cmb As ComboBox = inctrl
@@ -1200,20 +1202,25 @@ Public Class frmValidator
End Sub
Public Sub OnTextBoxFocus(sender As Object, e As EventArgs)
Dim oTextbox As TextBox = sender
Dim oTextbox As TextEdit = sender
Dim oMeta As ClassControlCreator.ControlMetadata = oTextbox.Tag
If DirectCast(oTextbox.Tag, ClassControlCreator.ControlMetadata).ReadOnly = False Then
If oMeta.ReadOnly = False Then
oTextbox.BackColor = Color.LightSteelBlue
oTextbox.ForeColor = GraphicsEx.GetContrastedColor(Color.LightSteelBlue)
oTextbox.SelectAll()
End If
End Sub
Public Sub OnTextBoxLostFocus(sender As System.Object, e As System.EventArgs)
Dim oTextbox As TextBox = sender
Dim oTextbox As TextEdit = sender
Dim oMeta As ClassControlCreator.ControlMetadata = oTextbox.Tag
If DirectCast(oTextbox.Tag, ClassControlCreator.ControlMetadata).ReadOnly = False Then
oTextbox.BackColor = Color.White
If oMeta.ReadOnly = False Then
oTextbox.BackColor = oMeta.BackColor
oTextbox.ForeColor = GraphicsEx.GetContrastedColor(oMeta.BackColor)
End If
SetControlValues_FromControl(oTextbox)
ClassControlCreator.GridTables_HandleControlValueChange(PanelValidatorControl, DT_COLUMNS_GRID_WITH_SQL_WITH_CTRL_PLACEHOLDER)
@@ -1232,7 +1239,7 @@ Public Class frmValidator
Exit Sub
End If
Dim oTextBox As TextBox = sender
Dim oTextBox As TextEdit = sender
If oTextBox.Text <> String.Empty And me_closing = False And _Indexe_Loaded = True And oTextBox.Height < 25 Then
If (e.KeyCode = Keys.Return) Or (e.KeyCode = Keys.Tab) Or (e.KeyCode = Keys.Enter) Then
@@ -1668,7 +1675,7 @@ Public Class frmValidator
'End Try
Select Case oControl.GetType()
Case GetType(TextBox)
Case GetType(TextEdit)
If oControlTextOption = "Replace" Then
oControl.Text = oControlCaption
Else
@@ -1833,7 +1840,7 @@ Public Class frmValidator
oFound = True
LOGGER.Debug($"Got the depending control ID:{oDEPENDING_GUID}..Setting the values..")
Select Case oControl.GetType.ToString
Case GetType(TextBox).ToString
Case GetType(TextEdit).ToString
Try
Dim oTEXT = oDTDEPENDING_RESULT.Rows(0).Item(0)
Try
@@ -1958,7 +1965,7 @@ Public Class frmValidator
oFound = True
LOGGER.Debug($"Got the depending control ID:{oDEPENDING_GUID}..Setting the values..")
Select Case oControl.GetType.ToString
Case GetType(TextBox).ToString
Case GetType(TextEdit).ToString
Try
Dim oTEXT = oDTDEPENDING_RESULT.Rows(0).Item(0)
Try
@@ -2336,7 +2343,7 @@ Public Class frmValidator
If displayboxname.StartsWith(ClassControlCreator.PREFIX_COMBOBOX) Then
LOGGER.Debug("Filling Combobox with Results")
Dim oCombobox As ComboBox = PanelValidatorControl.Controls(displayboxname)
Dim oCombobox As Windows.Forms.ComboBox = PanelValidatorControl.Controls(displayboxname)
If IsNothing(oCombobox) Then
Exit Sub
@@ -3137,13 +3144,14 @@ Public Class frmValidator
oControName = oControl.Name
Dim oLoadIndex As Boolean = oControlRow.Item("LOAD_IDX_VALUE")
LOGGER.Debug("INDEX: " & oSourceIndexName & " - CONTROLNAME: " & oControl.Name & " - LOAD IDXVALUES: " & oLoadIndex.ToString)
Select Case oType
Case "System.Windows.Forms.TextBox"
Case "DevExpress.XtraEditors.TextEdit"
Try
oControlType = "Textbox"
Dim oTextBox As TextEdit = oControl
Dim oMeta As ClassControlCreator.ControlMetadata = oTextBox.Tag
If oSourceIndexName = "" Then
MsgBox("Attention wrong configuration:" & vbNewLine & "for control " & oControl.Name & " no INDEX configured!" & vbNewLine & "Bitte prüfen Sie den Formulardesigner!", MsgBoxStyle.Critical)
Exit For
@@ -3151,7 +3159,7 @@ Public Class frmValidator
If oSourceIndexName Is Nothing = False Then
If oLoadIndex = False Or oSourceIndexName = "DD PM-ONLY FOR DISPLAY" Then
' Wenn kein Index exisitiert, defaultValue laden
oControl.Text = oDefaultValue
oTextBox.EditValue = oDefaultValue
LOGGER.Debug("Indexwert soll nicht geladen werden.")
Exit Select
End If
@@ -3186,14 +3194,15 @@ Public Class frmValidator
End If
Try
Dim oFormatString As String = oControlRow.ItemEx("CTRL_FORMAT_STRING", "")
oFormattedValue = ClassFormat.GetFormattedValue(oControl.Name, oValueFromSource, oFormatString)
'Dim oFormatString As String = oControlRow.ItemEx("CTRL_FORMAT_STRING", "")
'oFormattedValue = ClassFormat.GetFormattedValue(oControl.Name, oValueFromSource, oFormatString)
If Not IsNothing(oFormattedValue) And oFormattedValue <> String.Empty Then
oControl.Text = NotNull(oFormattedValue, oDefaultValue)
oTextBox.EditValue = NotNull(oFormattedValue, oDefaultValue)
Else
oControl.Text = NotNull(oValueFromSource, oDefaultValue)
oTextBox.EditValue = NotNull(oValueFromSource, oDefaultValue)
End If
Try
Dim oBackColor As String = oControlRow.Item("CTRL_BACKCOLOR_IF")
If oBackColor <> String.Empty Then
@@ -3209,14 +3218,11 @@ Public Class frmValidator
Dim oSQl = $"SELECT CASE WHEN {oExpression} THEN CONVERT(BIT,1) ELSE CONVERT(BIT,0) END "
Dim oColorName = IIf(DatabaseECM.GetScalarValue(oSQl), oSPlit(1), oSPlit(2))
oControl.BackColor = Color.FromName(oColorName)
oMeta.BackColor = oControl.BackColor
oControl.ForeColor = GraphicsEx.GetContrastedColor(oControl.BackColor)
'If oColorName = "Green" Or oColorName = "Blue" Or oColorName = "Red" Then
' oControl.ForeColor = Color.FromName("White")
'Else
' oControl.ForeColor = Color.FromName("Black")
'End If
End If
End If
Catch ex As Exception
@@ -3230,7 +3236,7 @@ Public Class frmValidator
Catch ex As Exception
LOGGER.Info("Error While converting defaultValue [" & oDefaultValue & "]: " & ex.Message)
oControl.Text = ""
oTextBox.EditValue = ""
End Try
@@ -3248,7 +3254,7 @@ Public Class frmValidator
Case "System.Windows.Forms.ComboBox"
oControlType = "ComboBox"
Dim oMyCombobox As ComboBox = oControl
Dim oMyCombobox As Windows.Forms.ComboBox = oControl
Try
If oSourceIndexName = "" Then
MsgBox("Attention wrong configuration:" & vbNewLine & "for control " & oControl.Name & " no INDEX configured!" & vbNewLine & "Bitte prüfen Sie den Formulardesigner!", MsgBoxStyle.Critical)
@@ -4294,7 +4300,7 @@ Public Class frmValidator
'######
Dim Type As String = oControl.GetType.ToString
Select Case Type
Case "System.Windows.Forms.TextBox"
Case "DevExpress.XtraEditors.TextEdit"
Try
value_from_control = oControl.Text
Catch ex As Exception
@@ -4450,14 +4456,16 @@ Public Class frmValidator
btnSave.Enabled = True
End Sub
Function Check_Missing(control As Control, typ As String)
Function Check_Missing(control As Control, typ As String) As Boolean
Select Case typ
Case "txt"
If control.Text = String.Empty Then
Dim oTextBox As TextEdit = control
If oTextBox.Text = String.Empty Then
Return True
End If
Return False
End Select
Return False
End Function
Function Return_PM_VEKTOR(input As String, VKTBezeichner As String)
Dim PM_String As String
@@ -4774,7 +4782,7 @@ Public Class frmValidator
End Try
Case "System.Windows.Forms.TextBox"
Case "DevExpress.XtraEditors.TextEdit"
Try
'Dim oWrongInputMessage = ClassAllgemeineFunktionen.GUI_LANGUAGE_INFO("frmValidator.WrongInputControl")
Dim oWrongInputMessage = S.Falsche_Eingabe
@@ -4899,7 +4907,7 @@ Public Class frmValidator
Case "System.Windows.Forms.ComboBox"
Try
LOGGER.Debug($"Working on Combobox...")
Dim cmb As ComboBox = oControl
Dim cmb As Windows.Forms.ComboBox = oControl
'Wenn kein Wert ausgewählt wurde und der Index aber gesetzt werden muss
If cmb.SelectedIndex = -1 And oIsRequired = True Then
oMissing = True