jj: Work in Progress: Vector Fields / Lookup Field
This commit is contained in:
parent
c5e59b617e
commit
d352487f29
@ -525,9 +525,13 @@ Public Class frmIndex
|
|||||||
table.Columns.RemoveAt(columnCount)
|
table.Columns.RemoveAt(columnCount)
|
||||||
End While
|
End While
|
||||||
|
|
||||||
|
Const LOOKUP_NO_RECORDS As String = "Keine Datensätze ausgewählt"
|
||||||
|
Const LOOKUP_N_RECORDS As String = "{0} Datensätze ausgewählt"
|
||||||
|
Const LOOKUP_CONTROL_HEIGHT As Integer = 24
|
||||||
|
|
||||||
Dim lookupButton As New Button()
|
Dim lookupButton As New Button()
|
||||||
lookupButton.Location = New Point(311, y - 1)
|
lookupButton.Location = New Point(311, y - 1)
|
||||||
lookupButton.Size = New Size(27, 27)
|
lookupButton.Size = New Size(LOOKUP_CONTROL_HEIGHT, LOOKUP_CONTROL_HEIGHT)
|
||||||
lookupButton.Image = My.Resources.gear_32xSM
|
lookupButton.Image = My.Resources.gear_32xSM
|
||||||
|
|
||||||
pnlIndex.Controls.Add(lookupButton)
|
pnlIndex.Controls.Add(lookupButton)
|
||||||
@ -536,16 +540,18 @@ Public Class frmIndex
|
|||||||
Dim listbox As New ListBox()
|
Dim listbox As New ListBox()
|
||||||
Dim gridLookup As New DevExpress.XtraEditors.GridLookUpEdit()
|
Dim gridLookup As New DevExpress.XtraEditors.GridLookUpEdit()
|
||||||
|
|
||||||
|
gridLookup.Name = "cmbMulti" & indexname
|
||||||
gridLookup.Font = New Font(gridLookup.Font.FontFamily, 10)
|
gridLookup.Font = New Font(gridLookup.Font.FontFamily, 10)
|
||||||
gridLookup.Location = New Point(11, y)
|
gridLookup.Location = New Point(11, y)
|
||||||
gridLookup.Size = New Size(300, 30)
|
gridLookup.Size = New Size(300, LOOKUP_CONTROL_HEIGHT)
|
||||||
|
|
||||||
' TODO: Hier noch die Vorbelegung für Vektor Indexe einfügen
|
' TODO: Hier noch die Vorbelegung für Vektor Indexe einfügen
|
||||||
gridLookup.Properties.DataSource = Nothing
|
gridLookup.Properties.DataSource = Nothing
|
||||||
gridLookup.Properties.PopupFormSize = New Size(gridLookup.Properties.PopupFormSize.Width, 100)
|
gridLookup.Properties.PopupFormSize = New Size(gridLookup.Properties.PopupFormSize.Width, 100)
|
||||||
gridLookup.Properties.NullText = $"Keine Datensätze ausgewählt"
|
gridLookup.Properties.NullText = LOOKUP_NO_RECORDS
|
||||||
|
|
||||||
' Da das gridLookup ein Readonly Control sein soll,
|
' Da das gridLookup ein Readonly Control sein soll,
|
||||||
' aber sich trotzdem öffnen lassen soll, müssen wir so das setzen eines neuen Werts verhindern
|
' sich aber trotzdem öffnen lassen soll, müssen wir so das setzen eines neuen Werts verhindern
|
||||||
AddHandler gridLookup.EditValueChanging, Sub(sender As Object, e As ChangingEventArgs)
|
AddHandler gridLookup.EditValueChanging, Sub(sender As Object, e As ChangingEventArgs)
|
||||||
e.Cancel = True
|
e.Cancel = True
|
||||||
End Sub
|
End Sub
|
||||||
@ -569,7 +575,7 @@ Public Class frmIndex
|
|||||||
If result = DialogResult.OK Then
|
If result = DialogResult.OK Then
|
||||||
Dim values As List(Of Object) = frm.SelectedValues
|
Dim values As List(Of Object) = frm.SelectedValues
|
||||||
gridLookup.Properties.DataSource = values
|
gridLookup.Properties.DataSource = values
|
||||||
gridLookup.Properties.NullText = IIf(values.Count = 0, "Keine Datensätze ausgewählt", $"{values.Count} Datensätze ausgewählt")
|
gridLookup.Properties.NullText = IIf(values.Count = 0, LOOKUP_NO_RECORDS, String.Format(LOOKUP_N_RECORDS, values.Count))
|
||||||
End If
|
End If
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
@ -577,8 +583,10 @@ Public Class frmIndex
|
|||||||
Else
|
Else
|
||||||
Dim textBox As New TextBox()
|
Dim textBox As New TextBox()
|
||||||
|
|
||||||
|
textBox.Name = "cmbSingle" & indexname
|
||||||
|
textBox.Font = New Font(textBox.Font.FontFamily, 9)
|
||||||
textBox.Location = New Point(11, y)
|
textBox.Location = New Point(11, y)
|
||||||
textBox.Size = New Size(300, 27)
|
textBox.Size = New Size(300, LOOKUP_CONTROL_HEIGHT)
|
||||||
|
|
||||||
AddHandler lookupButton.Click, Sub()
|
AddHandler lookupButton.Click, Sub()
|
||||||
Dim frm As New frmLookupGrid()
|
Dim frm As New frmLookupGrid()
|
||||||
@ -907,7 +915,43 @@ Public Class frmIndex
|
|||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
If ctrl.Name.StartsWith("cmb") Then
|
If ctrl.Name.StartsWith("cmbMulti") Then
|
||||||
|
Dim cmbMulti As DevExpress.XtraEditors.LookUpEdit = ctrl
|
||||||
|
|
||||||
|
If cmbMulti.Text = "" Then
|
||||||
|
Dim optional_index As Boolean = ClassDatabase.Execute_Scalar("SELECT OPTIONAL FROM TBDD_INDEX_MAN WHERE DOK_ID = " & dokartid & " AND NAME = '" & Replace(cmbMulti.Name, "cmbMulti", "") & "'", MyConnectionString, True)
|
||||||
|
|
||||||
|
If optional_index = False Then
|
||||||
|
MsgBox("Bitte wählen Sie einen Wert aus der Combobox.", MsgBoxStyle.Exclamation)
|
||||||
|
cmbMulti.Focus()
|
||||||
|
Return False
|
||||||
|
Else
|
||||||
|
Indexwert_Postprocessing(Replace(cmbMulti.Name, "cmbMulti", ""), "")
|
||||||
|
result = True
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
Indexwert_Postprocessing(Replace(cmbMulti.Name, "cmb", ""), cmbMulti.Text)
|
||||||
|
result = True
|
||||||
|
End If
|
||||||
|
ElseIf ctrl.Name.StartsWith("cmbSingle") Then
|
||||||
|
Dim cmbSingle As TextBox = ctrl
|
||||||
|
|
||||||
|
If cmbSingle.Text = "" Then
|
||||||
|
Dim optional_index As Boolean = ClassDatabase.Execute_Scalar("SELECT OPTIONAL FROM TBDD_INDEX_MAN WHERE DOK_ID = " & dokartid & " AND NAME = '" & Replace(cmbSingle.Name, "cmbMulti", "") & "'", MyConnectionString, True)
|
||||||
|
|
||||||
|
If optional_index = False Then
|
||||||
|
MsgBox("Bitte wählen Sie einen Wert aus der Combobox.", MsgBoxStyle.Exclamation)
|
||||||
|
cmbSingle.Focus()
|
||||||
|
Return False
|
||||||
|
Else
|
||||||
|
Indexwert_Postprocessing(Replace(cmbSingle.Name, "cmbMulti", ""), "")
|
||||||
|
result = True
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
Indexwert_Postprocessing(Replace(cmbSingle.Name, "cmb", ""), cmbSingle.Text)
|
||||||
|
result = True
|
||||||
|
End If
|
||||||
|
ElseIf ctrl.Name.StartsWith("cmb") Then
|
||||||
Dim cmb As ComboBox = ctrl
|
Dim cmb As ComboBox = ctrl
|
||||||
If cmb.Text = "" Then
|
If cmb.Text = "" Then
|
||||||
Dim optional_index As Boolean = ClassDatabase.Execute_Scalar("SELECT OPTIONAL FROM TBDD_INDEX_MAN WHERE DOK_ID = " & dokartid & " AND NAME = '" & Replace(cmb.Name, "cmb", "") & "'", MyConnectionString, True)
|
Dim optional_index As Boolean = ClassDatabase.Execute_Scalar("SELECT OPTIONAL FROM TBDD_INDEX_MAN WHERE DOK_ID = " & dokartid & " AND NAME = '" & Replace(cmb.Name, "cmb", "") & "'", MyConnectionString, True)
|
||||||
|
|||||||
13
Global_Indexer/frmLookupGrid.Designer.vb
generated
13
Global_Indexer/frmLookupGrid.Designer.vb
generated
@ -27,6 +27,7 @@ Partial Class frmLookupGrid
|
|||||||
Me.Panel1 = New System.Windows.Forms.Panel()
|
Me.Panel1 = New System.Windows.Forms.Panel()
|
||||||
Me.btnClear = New System.Windows.Forms.Button()
|
Me.btnClear = New System.Windows.Forms.Button()
|
||||||
Me.btnOK = New System.Windows.Forms.Button()
|
Me.btnOK = New System.Windows.Forms.Button()
|
||||||
|
Me.Button1 = New System.Windows.Forms.Button()
|
||||||
CType(Me.gridLookup, System.ComponentModel.ISupportInitialize).BeginInit()
|
CType(Me.gridLookup, System.ComponentModel.ISupportInitialize).BeginInit()
|
||||||
CType(Me.viewLookup, System.ComponentModel.ISupportInitialize).BeginInit()
|
CType(Me.viewLookup, System.ComponentModel.ISupportInitialize).BeginInit()
|
||||||
Me.Panel1.SuspendLayout()
|
Me.Panel1.SuspendLayout()
|
||||||
@ -56,6 +57,7 @@ Partial Class frmLookupGrid
|
|||||||
'
|
'
|
||||||
'Panel1
|
'Panel1
|
||||||
'
|
'
|
||||||
|
Me.Panel1.Controls.Add(Me.Button1)
|
||||||
Me.Panel1.Controls.Add(Me.btnClear)
|
Me.Panel1.Controls.Add(Me.btnClear)
|
||||||
Me.Panel1.Controls.Add(Me.btnOK)
|
Me.Panel1.Controls.Add(Me.btnOK)
|
||||||
Me.Panel1.Dock = System.Windows.Forms.DockStyle.Bottom
|
Me.Panel1.Dock = System.Windows.Forms.DockStyle.Bottom
|
||||||
@ -84,6 +86,15 @@ Partial Class frmLookupGrid
|
|||||||
Me.btnOK.Text = "OK"
|
Me.btnOK.Text = "OK"
|
||||||
Me.btnOK.UseVisualStyleBackColor = True
|
Me.btnOK.UseVisualStyleBackColor = True
|
||||||
'
|
'
|
||||||
|
'Button1
|
||||||
|
'
|
||||||
|
Me.Button1.Location = New System.Drawing.Point(100, 3)
|
||||||
|
Me.Button1.Name = "Button1"
|
||||||
|
Me.Button1.Size = New System.Drawing.Size(94, 23)
|
||||||
|
Me.Button1.TabIndex = 1
|
||||||
|
Me.Button1.Text = "RestoreSelect"
|
||||||
|
Me.Button1.UseVisualStyleBackColor = True
|
||||||
|
'
|
||||||
'frmLookupGrid
|
'frmLookupGrid
|
||||||
'
|
'
|
||||||
Me.AcceptButton = Me.btnOK
|
Me.AcceptButton = Me.btnOK
|
||||||
@ -92,6 +103,7 @@ Partial Class frmLookupGrid
|
|||||||
Me.ClientSize = New System.Drawing.Size(295, 269)
|
Me.ClientSize = New System.Drawing.Size(295, 269)
|
||||||
Me.Controls.Add(Me.gridLookup)
|
Me.Controls.Add(Me.gridLookup)
|
||||||
Me.Controls.Add(Me.Panel1)
|
Me.Controls.Add(Me.Panel1)
|
||||||
|
Me.KeyPreview = True
|
||||||
Me.MaximizeBox = False
|
Me.MaximizeBox = False
|
||||||
Me.MinimizeBox = False
|
Me.MinimizeBox = False
|
||||||
Me.Name = "frmLookupGrid"
|
Me.Name = "frmLookupGrid"
|
||||||
@ -109,4 +121,5 @@ Partial Class frmLookupGrid
|
|||||||
Friend WithEvents Panel1 As Panel
|
Friend WithEvents Panel1 As Panel
|
||||||
Friend WithEvents btnOK As Button
|
Friend WithEvents btnOK As Button
|
||||||
Friend WithEvents btnClear As Button
|
Friend WithEvents btnClear As Button
|
||||||
|
Friend WithEvents Button1 As Button
|
||||||
End Class
|
End Class
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
Imports DevExpress.XtraGrid.Views.Grid
|
Imports DevExpress.Data
|
||||||
|
Imports DevExpress.XtraGrid.Controls
|
||||||
|
Imports DevExpress.XtraGrid.Views.Base
|
||||||
|
Imports DevExpress.XtraGrid.Views.Grid
|
||||||
|
|
||||||
Public Class frmLookupGrid
|
Public Class frmLookupGrid
|
||||||
Public Property MultiSelect As Boolean
|
Public Property MultiSelect As Boolean
|
||||||
@ -34,23 +37,52 @@ Public Class frmLookupGrid
|
|||||||
' Ursprüngliche Werte zwischenspeichern
|
' Ursprüngliche Werte zwischenspeichern
|
||||||
originalValues = SelectedValues
|
originalValues = SelectedValues
|
||||||
|
|
||||||
|
SyncItemsWithView(view)
|
||||||
|
|
||||||
|
' Focus auf Find panel setzen
|
||||||
|
view.ShowFindPanel()
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub frmLookupGrid_Shown(sender As Object, e As EventArgs) Handles Me.Shown
|
||||||
|
Dim findEditor As DevExpress.XtraEditors.MRUEdit = gridLookup.Controls.Find("teFind", True).FirstOrDefault()
|
||||||
|
If findEditor IsNot Nothing Then
|
||||||
|
'AddHandler findEditor.KeyUp, AddressOf FindPanel_KeyUp
|
||||||
|
AddHandler findEditor.EditValueChanged, AddressOf FindPanel_KeyUp
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Private OldFindPanelValue As String = ""
|
||||||
|
|
||||||
|
Private Sub FindPanel_KeyUp(sender As Object, e As EventArgs)
|
||||||
|
Dim findEditor As DevExpress.XtraEditors.MRUEdit = sender
|
||||||
|
|
||||||
|
If findEditor.EditValue.ToString.Count = 0 And OldFindPanelValue.Count > 0 Then
|
||||||
|
SyncItemsWithView(viewLookup)
|
||||||
|
End If
|
||||||
|
|
||||||
|
OldFindPanelValue = findEditor.EditValue
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub SyncItemsWithView(view As GridView)
|
||||||
' Wenn Vorbelegungen existieren
|
' Wenn Vorbelegungen existieren
|
||||||
' und Mehrfachauswahl ausgewählt ist, werden diese angehakt
|
' und Mehrfachauswahl ausgewählt ist, werden diese angehakt
|
||||||
If SelectedValues.Count > 0 And MultiSelect Then
|
If SelectedValues.Count > 0 And MultiSelect Then
|
||||||
For i = 0 To view.DataRowCount - 1
|
For i = 0 To view.DataRowCount - 1
|
||||||
Dim rowHandle = view.GetRowHandle(i)
|
Dim rowHandle = view.GetRowHandle(i)
|
||||||
Dim rowView As DataRowView = view.GetRow(rowHandle)
|
Dim rowView As DataRowView = view.GetRow(rowHandle)
|
||||||
Dim row As DataRow = rowView.Row
|
|
||||||
Dim value = row.Item(0)
|
|
||||||
|
|
||||||
If SelectedValues.Contains(value) Then
|
If rowView IsNot Nothing Then
|
||||||
view.SelectRow(rowHandle)
|
Dim row As DataRow = rowView.Row
|
||||||
|
Dim value = row.Item(0)
|
||||||
|
|
||||||
|
If SelectedValues.Contains(value) Then
|
||||||
|
view.SelectRow(rowHandle)
|
||||||
|
End If
|
||||||
End If
|
End If
|
||||||
Next
|
Next
|
||||||
End If
|
End If
|
||||||
|
|
||||||
' Focus auf Find panel setzen
|
|
||||||
view.ShowFindPanel()
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub btnOK_Click(sender As Object, e As EventArgs) Handles btnOK.Click
|
Private Sub btnOK_Click(sender As Object, e As EventArgs) Handles btnOK.Click
|
||||||
@ -74,4 +106,28 @@ Public Class frmLookupGrid
|
|||||||
Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
|
Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
|
||||||
SelectedValues = New List(Of Object)
|
SelectedValues = New List(Of Object)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Private Sub frmLookupGrid_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown
|
||||||
|
If e.KeyCode = Keys.Escape Then
|
||||||
|
Close()
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub viewLookup_SelectionChanged(sender As Object, e As DevExpress.Data.SelectionChangedEventArgs) Handles viewLookup.SelectionChanged
|
||||||
|
If e.Action = System.ComponentModel.CollectionChangeAction.Add Then
|
||||||
|
Dim row = viewLookup.GetRow(e.ControllerRow)
|
||||||
|
Dim value As Object = row.item(0)
|
||||||
|
|
||||||
|
SelectedValues.Add(value)
|
||||||
|
ElseIf e.Action = System.ComponentModel.CollectionChangeAction.Remove Then
|
||||||
|
Dim row = viewLookup.GetRow(e.ControllerRow)
|
||||||
|
Dim value As Object = row.item(0)
|
||||||
|
|
||||||
|
SelectedValues = (From v In SelectedValues
|
||||||
|
Where v <> value
|
||||||
|
Select v).ToList()
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
End Class
|
End Class
|
||||||
Loading…
x
Reference in New Issue
Block a user