jj: Lookup Grid / Work in Progress

This commit is contained in:
Jonathan Jenne
2018-08-03 15:36:08 +02:00
parent ea6f73af18
commit c5e59b617e
11 changed files with 1202 additions and 1485 deletions

View File

@@ -8,6 +8,7 @@ Imports System.Text
Imports System.Security.AccessControl
Imports System.Security.Principal
Imports System.DirectoryServices
Imports DevExpress.XtraEditors.Controls
Public Class frmIndex
#Region "+++++ Variablen ++++++"
@@ -468,7 +469,7 @@ Public Class frmIndex
End Try
End Function
' <STAThread()> _
Private Sub AddVorschlag_ComboBox(indexname As String, y As Integer, conid As Integer, sql_Vorschlag As String, Optional Vorgabe As String = "")
Private Sub AddVorschlag_ComboBox(indexname As String, y As Integer, conid As Integer, sql_Vorschlag As String, Multiselect As Boolean, Optional Vorgabe As String = "")
Try
Dim connectionString As String
Dim sqlCnn As SqlConnection
@@ -509,50 +510,137 @@ Public Class frmIndex
If LogErrorsOnly = False Then ClassLogger.Add(" >>sql enthält Platzhalter und wird erst während der Laufzeit gefüllt!", False)
End If
Dim newCMB As ComboBox
If runinLZ = True Then
'Die Standardcombobox anlegen
newCMB = addCombobox(indexname, y)
newCMB.Size = New Size(300, 27)
Else
If NewDataset.Tables(0).Rows.Count > 0 Then
'Die Standardcombobox anlegen
newCMB = addCombobox(indexname, y)
Dim table As DataTable = NewDataset.Tables(0)
If table.Rows.Count > 0 Then
Dim columnCount = 1
newCMB.DataSource = NewDataset.Tables(0)
newCMB.DisplayMember = NewDataset.Tables(0).Columns(0).ColumnName
While (table.Columns.Count > columnCount)
table.Columns.RemoveAt(columnCount)
End While
'Die Standargrösse definieren
'Dim newWidth As Integer = 300
'For i = 0 To NewDataset.Tables(0).Rows.Count - 1
' 'MsgBox(NewDataset.Tables(0).Rows(i).Item(0))
' AddComboBoxValue(newCMB, NewDataset.Tables(0).Rows(i).Item(0))
' Try
' Dim text As String = NewDataset.Tables(0).Rows(i).Item(0)
' If text.Length > 15 Then
' Dim g As Graphics = newCMB.CreateGraphics
' If g.MeasureString(text, newCMB.Font).Width + 30 > newWidth Then
' newWidth = g.MeasureString(text, newCMB.Font).Width + 30
' End If
' g.Dispose()
' End If
' Catch ex As Exception
' MsgBox(ex.Message, MsgBoxStyle.Critical, "Unexpected error in Anpassung Breite ComboBox:")
' End Try
Dim lookupButton As New Button()
lookupButton.Location = New Point(311, y - 1)
lookupButton.Size = New Size(27, 27)
lookupButton.Image = My.Resources.gear_32xSM
'Next
'newCMB.Size = New Size(newWidth, 27)
newCMB.AutoCompleteSource = AutoCompleteSource.ListItems
newCMB.AutoCompleteMode = AutoCompleteMode.Suggest
newCMB.DropDownHeight = (newCMB.ItemHeight + 0.2) * 25
If Vorgabe <> "" Then
newCMB.SelectedIndex = newCMB.FindStringExact(Vorgabe)
newCMB.Text = Vorgabe
Get_NextComboBoxResults(newCMB)
pnlIndex.Controls.Add(lookupButton)
If Multiselect Then
Dim listbox As New ListBox()
Dim gridLookup As New DevExpress.XtraEditors.GridLookUpEdit()
gridLookup.Font = New Font(gridLookup.Font.FontFamily, 10)
gridLookup.Location = New Point(11, y)
gridLookup.Size = New Size(300, 30)
' TODO: Hier noch die Vorbelegung für Vektor Indexe einfügen
gridLookup.Properties.DataSource = Nothing
gridLookup.Properties.PopupFormSize = New Size(gridLookup.Properties.PopupFormSize.Width, 100)
gridLookup.Properties.NullText = $"Keine Datensätze ausgewählt"
' Da das gridLookup ein Readonly Control sein soll,
' aber sich trotzdem öffnen lassen soll, müssen wir so das setzen eines neuen Werts verhindern
AddHandler gridLookup.EditValueChanging, Sub(sender As Object, e As ChangingEventArgs)
e.Cancel = True
End Sub
With gridLookup.Properties.View
.OptionsBehavior.ReadOnly = True
.OptionsBehavior.Editable = False
.OptionsView.ShowColumnHeaders = False
End With
AddHandler lookupButton.Click, Sub()
Dim frm As New frmLookupGrid()
frm.MultiSelect = True
frm.DataSource = table
frm.StartPosition = FormStartPosition.Manual
frm.SelectedValues = gridLookup.Properties.DataSource
frm.Location = pnlIndex.PointToScreen(New Point(340, y))
Dim result = frm.ShowDialog()
If result = DialogResult.OK Then
Dim values As List(Of Object) = frm.SelectedValues
gridLookup.Properties.DataSource = values
gridLookup.Properties.NullText = IIf(values.Count = 0, "Keine Datensätze ausgewählt", $"{values.Count} Datensätze ausgewählt")
End If
End Sub
pnlIndex.Controls.Add(gridLookup)
Else
Dim textBox As New TextBox()
textBox.Location = New Point(11, y)
textBox.Size = New Size(300, 27)
AddHandler lookupButton.Click, Sub()
Dim frm As New frmLookupGrid()
frm.MultiSelect = False
frm.DataSource = table
frm.StartPosition = FormStartPosition.Manual
frm.SelectedValues = New List(Of Object) From {textBox.Text}
frm.Location = pnlIndex.PointToScreen(New Point(340, y))
Dim result = frm.ShowDialog()
If result = DialogResult.OK Then
Dim value = frm.SelectedValues.FirstOrDefault()
textBox.Text = value
End If
End Sub
pnlIndex.Controls.Add(textBox)
End If
' Für ergebnisse die kleiner/gleich MAX_COMBOBOX_ITEMS sind
' die normale ComboBox verwenden
'If table.Rows.Count <= MAX_COMBOBOX_ITEMS Then
' 'Die Standardcombobox anlegen
' newCMB = addCombobox(indexname, y)
' newCMB.DataSource = table
' newCMB.DisplayMember = table.Columns(0).ColumnName
' newCMB.AutoCompleteSource = AutoCompleteSource.ListItems
' newCMB.AutoCompleteMode = AutoCompleteMode.Suggest
' newCMB.DropDownHeight = (newCMB.ItemHeight + 0.2) * 25
' If Vorgabe <> "" Then
' newCMB.SelectedIndex = newCMB.FindStringExact(Vorgabe)
' newCMB.Text = Vorgabe
' Get_NextComboBoxResults(newCMB)
' End If
'Else
' Dim searchLookup As New DevExpress.XtraEditors.SearchLookUpEdit()
' searchLookup.Properties.DataSource = table
' searchLookup.Properties.DisplayMember = table.Columns(0).ColumnName
' searchLookup.Properties.ValueMember = table.Columns(0).ColumnName
' searchLookup.Location = New Point(11, y)
' searchLookup.Size = New Size(300, 27)
' searchLookup.Properties.AppearanceFocused.BackColor = Color.Lime
' searchLookup.Properties.AppearanceFocused.BackColor2 = Color.Lime
' AddHandler searchLookup.EditValueChanged, Sub(sender As Object, e As EventArgs)
' SendKeys.Send("{TAB}")
' End Sub
' If Vorgabe <> String.Empty Then
' searchLookup.EditValue = Vorgabe
' End If
' pnlIndex.Controls.Add(searchLookup)
'End If
Else
End If
@@ -1946,8 +2034,10 @@ Public Class frmIndex
ShowError("Keine Manuellen Indizes für die " & vbNewLine & "Dokumentart " & cmbDokumentart.Text & " definiert")
ClassLogger.Add(" - Keine Manuellen Indizes für die " & vbNewLine & "Dokumentart " & cmbDokumentart.Text & " definiert")
End If
For Each DR In DT_INDEXEMAN.Rows
For Each DR As DataRow In DT_INDEXEMAN.Rows
Dim type = DR.Item("DATATYPE")
Dim MultiSelect As Boolean = DR.Item("MULTISELECT")
If type <> "BOOLEAN" Then
addLabel(DR.Item("NAME"), DR.Item("COMMENT").ToString, ylbl, anz)
End If
@@ -1966,7 +2056,7 @@ Public Class frmIndex
End If
Case "INTEGER"
If DR.Item("SUGGESTION") = True And DR.Item("SQL_RESULT").ToString.Length > 0 Then
AddVorschlag_ComboBox(DR.Item("NAME"), y, DR.Item("CONNECTION_ID"), DR.Item("SQL_RESULT"), DefaultValue)
AddVorschlag_ComboBox(DR.Item("NAME"), y, DR.Item("CONNECTION_ID"), DR.Item("SQL_RESULT"), MultiSelect, DefaultValue)
'AddAutoSuggest_Textbox(DR.Item("NAME"), y, DR.Item("CONNECTION_ID"), DR.Item("SQL_RESULT"), DefaultValue)
Else
Dim VORBELGUNG As Integer = DefaultValue
@@ -1975,7 +2065,7 @@ Public Class frmIndex
End If
Case "VARCHAR"
If DR.Item("SUGGESTION") = True And DR.Item("SQL_RESULT").ToString.Length > 0 Then
AddVorschlag_ComboBox(DR.Item("NAME"), y, DR.Item("CONNECTION_ID"), DR.Item("SQL_RESULT"), DefaultValue)
AddVorschlag_ComboBox(DR.Item("NAME"), y, DR.Item("CONNECTION_ID"), DR.Item("SQL_RESULT"), MultiSelect, DefaultValue)
'AddAutoSuggest_Textbox(DR.Item("NAME"), y, DR.Item("CONNECTION_ID"), DR.Item("SQL_RESULT"), DefaultValue)
Else
If DR.Item("NAME").ToString.ToLower = "dateiname" Then