diff --git a/app/DD_PM_WINDREAM/ClassControlCreator.vb b/app/DD_PM_WINDREAM/ClassControlCreator.vb index 736c9d6..bb626a0 100644 --- a/app/DD_PM_WINDREAM/ClassControlCreator.vb +++ b/app/DD_PM_WINDREAM/ClassControlCreator.vb @@ -517,132 +517,13 @@ Public Class ClassControlCreator AddHandler oView.CustomRowCellEdit, Sub(sender As Object, e As CustomRowCellEditEventArgs) Try For Each oRow As DataRow In DT_MY_COLUMNS.Rows - If oRow.Item("SPALTENNAME") <> e.Column.FieldName Then - Continue For + Dim oColumnName = oRow.Item("SPALTENNAME") + Dim oEditorExists = GridTables_TestEditorExistsByControlAndColumn(oControlId, oColumnName) + + If oColumnName = e.Column.FieldName And oEditorExists Then + Dim oEditor = GridTables.Item(oControlId).Item(oColumnName) + e.RepositoryItem = oEditor End If - - If Not GridTables.Item(oControlId).ContainsKey(e.Column.FieldName) Then - Continue For - End If - - Dim oEditor = GridTables.Item(oControlId).Item(e.Column.FieldName) - - e.RepositoryItem = oEditor - - -#Region "Old Stuff" - - - - 'Dim oComboboxDataTable As DataTable = GridTables.Item(oControlId).Item(e.Column.FieldName) - - 'If oComboboxDataTable Is Nothing Then - ' Throw New ApplicationException($"ComboboxTable for Column {e.Column.FieldName} is empty.") - 'End If - - - 'If oRow.Item("ADVANCED_LOOKUP") Then - - ' Dim oEditor = New RepositoryItemLookupControl3 - - ' If oComboboxDataTable IsNot Nothing Then - ' oEditor.DisplayMember = oComboboxDataTable.Columns.Item(0).ColumnName - ' oEditor.ValueMember = oComboboxDataTable.Columns.Item(0).ColumnName - ' oEditor.DataSource = oComboboxDataTable - ' End If - - ' 'AddHandler oEditor.SelectedValuesChanged, Sub(_sender As Object, _e As List(Of String)) - ' ' oView.PostEditor() - ' ' End Sub - - ' 'AddHandler oEditor.BeforePopup, Sub(_sender As Object, _e As EventArgs) - ' ' MsgBox("oEditor.BeforePopup") - ' ' Dim oConnectionId As Integer = NotNull(oRow.Item("CONNECTION_ID"), 0) - ' ' Dim oSqlCommand As String = NotNull(oRow.Item("SQL_COMMAND"), "") - ' ' oSqlCommand = clsPatterns.ReplaceAllValues(oSqlCommand, pPanel, True) - - ' ' Dim oTable = ClassDatabase.Return_Datatable_ConId(oSqlCommand, oConnectionId) - ' ' oEditor.DataSource = oTable - ' ' oEditor.DisplayMember = oComboboxDataTable.Columns.Item(0).ColumnName - ' ' oEditor.ValueMember = oComboboxDataTable.Columns.Item(0).ColumnName - ' ' End Sub - - ' 'AddHandler oEditor.QueryPopUp, Sub() - ' ' MsgBox("oEditor.QueryPopUp") - - ' ' End Sub - - ' 'AddHandler oEditor.Popup, Sub() - ' ' MsgBox("oEditor.Popup") - - ' ' End Sub - - ' 'AddHandler oEditor.ButtonClick, Sub() - ' ' MsgBox("oEditor.ButtonClick") - - ' ' End Sub - - ' AddHandler oEditor.ButtonPressed, Sub(_sender As Object, _e As EventArgs) - ' Dim oEditor2 = DirectCast(_sender, LookupControl3) - - ' 'MsgBox("oEditor.ButtonPressed") - ' Dim oConnectionId As Integer = NotNull(oRow.Item("CONNECTION_ID"), 0) - ' Dim oSqlCommand As String = NotNull(oRow.Item("SQL_COMMAND"), "") - ' oSqlCommand = clsPatterns.ReplaceAllValues(oSqlCommand, pPanel, True) - - ' Dim oTable = ClassDatabase.Return_Datatable_ConId(oSqlCommand, oConnectionId) - - ' If oTable IsNot Nothing Then - ' oEditor2.Properties.ValueMember = oTable.Columns.Item(0).ColumnName - ' oEditor2.Properties.DisplayMember = oTable.Columns.Item(0).ColumnName - ' oEditor2.Properties.DataSource = oTable - ' oEditor2.DoValidate(PopupCloseMode.Normal) - ' End If - - ' End Sub - - - - ' e.RepositoryItem = oEditor - 'Else - ' If oComboboxDataTable Is Nothing Then - ' Dim oConnectionId As Integer = NotNull(oRow.Item("CONNECTION_ID"), 0) - ' Dim oSqlCommand As String = NotNull(oRow.Item("SQL_COMMAND"), "") - ' oSqlCommand = clsPatterns.ReplaceAllValues(oSqlCommand, pPanel, True) - - ' oComboboxDataTable = ClassDatabase.Return_Datatable_ConId(oSqlCommand, oConnectionId) - ' End If - - ' If oComboboxDataTable Is Nothing Then - ' Continue For - ' End If - - ' Dim oEditor = New RepositoryItemComboBox() - ' Dim oItems As New List(Of String) - - ' 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 As DataRow In oComboboxDataTable.Rows - ' Dim oValue = oRow2.Item(0) - - ' Try - ' oValue &= $" | {oRow2.Item(1)}" - ' Catch ex As Exception - ' End Try - - ' oEditor.Items.Add(oValue) - ' oItems.Add(oValue) - ' Next - - ' e.RepositoryItem = oEditor - 'End If -#End Region Next Catch ex As Exception LOGGER.Warn("Error in CustomRowCellEdit for [{0}]", e.CellValue) @@ -849,10 +730,6 @@ Public Class ClassControlCreator End Sub Public Shared Function GridTables_GetRepositoryItemForColumn(pColumnName As String, pDataTable As DataTable, pIsAdvancedLookup As Boolean) As RepositoryItem - If pDataTable Is Nothing Then - Return Nothing - End If - If pIsAdvancedLookup Then Dim oEditor = New RepositoryItemLookupControl3 @@ -876,19 +753,36 @@ Public Class ClassControlCreator End If End Sub - For Each oRow2 As DataRow In pDataTable.Rows - Dim oValue = oRow2.Item(0) - Try - oValue &= $" | {oRow2.Item(1)}" - Catch ex As Exception - End Try + If pDataTable IsNot Nothing Then + For Each oRow2 As DataRow In pDataTable.Rows + Dim oValue = oRow2.Item(0) - oEditor.Items.Add(oValue) - oItems.Add(oValue) - Next + Try + oValue &= $" | {oRow2.Item(1)}" + Catch ex As Exception + End Try + + oEditor.Items.Add(oValue) + oItems.Add(oValue) + Next + End If Return oEditor End If End Function + + Private Shared Function GridTables_TestEditorExistsByControlAndColumn(oControlId As Integer, pColumn As String) As Boolean + If GridTables.ContainsKey(oControlId) Then + Dim oContainsKey = GridTables.Item(oControlId).ContainsKey(pColumn) + If oContainsKey AndAlso GridTables.Item(oControlId).Item(pColumn) IsNot Nothing Then + Return True + Else + Return False + End If + Else + Return False + End If + End Function + End Class diff --git a/app/DD_PM_WINDREAM/frmValidator.vb b/app/DD_PM_WINDREAM/frmValidator.vb index 67b82ad..8057c2f 100644 --- a/app/DD_PM_WINDREAM/frmValidator.vb +++ b/app/DD_PM_WINDREAM/frmValidator.vb @@ -1147,6 +1147,21 @@ Public Class frmValidator ClassControlCreator.GridTables_CacheDatatableForColumn(oControlId, oColumnName, oSqlStatement, oConnectionId, oAdvancedLookup) + ' === Block to force setting the editor for GridColumns + For Each oControl As Control In pnldesigner.Controls + Try + Dim oMeta = DirectCast(oControl.Tag, ClassControlCreator.ControlMetadata) + If oMeta.Guid = oControlId AndAlso TypeOf oControl Is GridControl Then + Dim oGrid As GridControl = DirectCast(oControl, GridControl) + DirectCast(oGrid.FocusedView, GridView).FocusInvalidRow() + Exit For + End If + Catch ex As Exception + LOGGER.Error(ex) + End Try + Next + ' === End + End If Catch ex As Exception LOGGER.Error(ex)