Move to LookupControl3 for Globix

This commit is contained in:
Jonathan Jenne
2021-03-22 15:58:20 +01:00
parent a34c29d8e2
commit 21bf3a7d32
7 changed files with 170 additions and 34 deletions

View File

@@ -2,8 +2,8 @@
Imports System.Drawing
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Language.Utils
Imports DigitalData.Controls.LookupGrid
Imports DevExpress.XtraEditors
Imports DigitalData.Controls.LookupGrid
Public Class ControlCreator
Private Form As Form
@@ -171,11 +171,8 @@ Public Class ControlCreator
End Try
End Function
Public Function AddLookupControl(pIndexname As String, pY As Integer, pMultiselect As Boolean, pDataType As String, pSQLCommand As String, pConnectionId As Integer, Optional pDefaultValue As String = "", Optional pAddNewValues As Boolean = False, Optional pPreventDuplicateValues As Boolean = False)
Dim oControl As New LookupControl2 With {
.MultiSelect = pMultiselect,
.AllowAddNewValues = pAddNewValues,
.PreventDuplicates = pPreventDuplicateValues,
Public Function AddLookupControl(pIndexname As String, pY As Integer, pMultiselect As Boolean, pDataType As String, pSQLCommand As String, pConnectionId As Integer, Optional pDefaultValue As String = "", Optional pAddNewValues As Boolean = False, Optional pPreventDuplicateValues As Boolean = False) As LookupControl3
Dim oControl As New LookupControl3 With {
.Location = New Point(DEFAULT_POSITION_X, pY),
.Size = New Size(DEFAULT_WIDTH, DEFAULT_HEIGHT),
.Name = "cmbMulti" & pIndexname,
@@ -184,6 +181,10 @@ Public Class ControlCreator
.IndexType = pDataType
}
}
oControl.Properties.MultiSelect = pMultiselect
oControl.Properties.AllowAddNewValues = pAddNewValues
oControl.Properties.PreventDuplicates = pPreventDuplicateValues
oControl.Properties.AppearanceFocused.BackColor = HightlightColor
If Not String.IsNullOrEmpty(pDefaultValue) Then
@@ -200,18 +201,27 @@ Public Class ControlCreator
Select(Function(item) item.Trim()).
ToList()
End If
oControl.SelectedValues = oDefaultValues
oControl.Properties.SelectedValues = oDefaultValues
End If
AddHandler oControl.SelectedValuesChanged, Sub() OnControlChanged.Invoke(oControl)
AddHandler oControl.Properties.SelectedValuesChanged, Sub() OnControlChanged.Invoke(oControl)
If OnLookupData Is Nothing Then
Logger.Warn("LookupGrid Datasource could not be set, OnLookupData Function is not defined!")
End If
Try
Dim oDataSource = OnLookupData.Invoke(oControl, pSQLCommand, pConnectionId)
oControl.DataSource = oDataSource
If pSQLCommand IsNot Nothing AndAlso pSQLCommand.Length > 0 Then
Dim oDataSource = OnLookupData.Invoke(oControl, pSQLCommand, pConnectionId)
oControl.Properties.DataSource = oDataSource
If oDataSource IsNot Nothing AndAlso oDataSource.Columns.Count > 0 Then
oControl.Properties.DisplayMember = oDataSource.Columns.Item(0).ColumnName
oControl.Properties.ValueMember = oDataSource.Columns.Item(0).ColumnName
Else
Logger.Warn("Lookup {0} Datasource did not contain any columns!", oControl.Name)
End If
End If
Catch ex As Exception
Logger.Error(ex)
End Try