diff --git a/app/DD_PM_WINDREAM/ClassControlCreator.vb b/app/DD_PM_WINDREAM/ClassControlCreator.vb index d43de9d..9973afc 100644 --- a/app/DD_PM_WINDREAM/ClassControlCreator.vb +++ b/app/DD_PM_WINDREAM/ClassControlCreator.vb @@ -1,8 +1,10 @@ -Imports DD_LIB_Standards +Imports System.ComponentModel +Imports DD_LIB_Standards Imports DevExpress.Utils Imports DevExpress.XtraEditors Imports DevExpress.XtraEditors.Controls Imports DevExpress.XtraEditors.NavigatorButtons +Imports DevExpress.XtraEditors.Repository Imports DevExpress.XtraGrid Imports DevExpress.XtraGrid.Views.Base Imports DevExpress.XtraGrid.Views.Grid @@ -386,7 +388,7 @@ Public Class ClassControlCreator oControl.ForceInitialize() - oView = oControl.DefaultView + oView = oControl.MainView oView.OptionsView.ShowGroupPanel = False oControl.ContextMenu = Nothing @@ -422,7 +424,11 @@ Public Class ClassControlCreator End With + Dim oTables As New Dictionary(Of String, DataTable) + For Each oRow As DD_DMSLiteDataSet.TBPM_CONTROL_TABLERow In columns + ' Create Columns in Datatable + Dim oColumn = New DataColumn() With { .DataType = GetType(String), .ColumnName = oRow.SPALTENNAME, @@ -431,11 +437,57 @@ Public Class ClassControlCreator } oDatatable.Columns.Add(oColumn) + + ' Fetch and cache Combobox results + Dim oConnectionId As Integer = NotNull(oRow.Item("CONNECTION_ID"), 0) + Dim oSqlCommand As String = NotNull(oRow.Item("SQL_COMMAND"), "") + + If oConnectionId > 0 And oSqlCommand <> "" Then + Try + Dim oComboboxDataTable As DataTable = ClassDatabase.Return_Datatable_ConId(oSqlCommand, oConnectionId) + oTables.Add(oRow.SPALTENNAME, oComboboxDataTable) + Catch ex As Exception + LOGGER.Warn("Could not load data for column {0} in control {1}", oRow.SPALTENNAME, oControl.Name) + LOGGER.Error(ex) + End Try + End If Next oControl.DataSource = oDatatable + oControl.RefreshDataSource() + oControl.ForceInitialize() AddHandler oView.CellValueChanged, AddressOf HandleCellValueChanged + AddHandler oView.CustomRowCellEdit, Sub(sender As Object, e As CustomRowCellEditEventArgs) + For Each oRow As DD_DMSLiteDataSet.TBPM_CONTROL_TABLERow In columns + If oRow.SPALTENNAME = e.Column.FieldName Then + + If oTables.ContainsKey(e.Column.FieldName) Then + Dim oComboboxDataTable As DataTable = oTables.Item(e.Column.FieldName) + Dim oEditor As New RepositoryItemComboBox() + Dim oItems As New List(Of String) + + oEditor.AutoComplete = True + AddHandler oEditor.Validating, Sub(_sender As ComboBoxEdit, _e As CancelEventArgs) + If oItems.Contains(_sender.EditValue) Then + _e.Cancel = False + Else + _e.Cancel = True + End If + + End Sub + + For Each oRow2 In oComboboxDataTable.Rows + Dim oValue = oRow2.item(0) + oEditor.Items.Add(oValue) + oItems.Add(oValue) + Next + + e.RepositoryItem = oEditor + End If + End If + Next + End Sub Return oControl End Function @@ -450,6 +502,8 @@ Public Class ClassControlCreator Dim foo = 1 End Function + + Public Shared Function CreateExistingLine(row As DataRow, designMode As Boolean) As LineLabel Dim control As LineLabel = CreateBaseControl(New LineLabel(), row, designMode) control.Text = "------------------------------"