3 Commits

Author SHA1 Message Date
Jonathan Jenne
96f3ece84e TestGUI: update test 2021-04-07 12:28:55 +02:00
Jonathan Jenne
11908ab246 LookupGrid: Update Datasource when new value is added 2021-04-07 12:28:40 +02:00
Jonathan Jenne
2450977fc3 GlobalIndexer: Revert setting up handler before default value 2021-04-07 12:27:04 +02:00
4 changed files with 36 additions and 12 deletions

View File

@@ -229,6 +229,16 @@ Public Class RepositoryItemLookupControl3
If oResult = Windows.Forms.DialogResult.OK Then
Dim oValues = oForm.SelectedValues
UpdateSelectedValues(oValues)
If oForm.NewValues.Count > 0 AndAlso TypeOf DataSource Is DataTable Then
Dim oTable As DataTable = DirectCast(DataSource, DataTable)
For Each oValue In oForm.NewValues
Dim oRow = oTable.NewRow()
oRow.Item(0) = oValue
oTable.Rows.Add(oRow)
Next
End If
End If
End Using
End If

View File

@@ -9,6 +9,9 @@ Public Class frmLookupGrid
Public Property PreventDuplicates As Boolean
Public Property DataSource As DataTable
Public Property SelectedValues As List(Of String)
Public Property NewValues As New HashSet(Of String)
Public Const COLUMN_SELECTED = "SELECTED"
Private _DataColumn As Integer
Private _DataSourceTemp As DataTable
@@ -29,7 +32,7 @@ Public Class frmLookupGrid
End If
If MultiSelect Then
If Not _DataSourceTemp.Columns.Contains("SELECTED") Then
If Not _DataSourceTemp.Columns.Contains(COLUMN_SELECTED) Then
Dim selectedColumn = New DataColumn() With {
.ColumnName = "SELECTED",
.DataType = GetType(Boolean),
@@ -96,7 +99,7 @@ Public Class frmLookupGrid
For oIndex = 0 To viewLookup.DataRowCount - 1
Dim oRow As DataRow = _View.GetDataRow(oIndex)
Dim oSelected As Boolean = oRow.Item(0)
Dim oValue As Object = oRow.Item(1)
Dim oValue As Object = GetValueFromRow(oRow)
If oSelected Then
oValues.Add(oValue)
@@ -115,7 +118,7 @@ Public Class frmLookupGrid
Dim oValues As New List(Of String)
If oRow IsNot Nothing Then
Dim oValue = oRow.Item(0)
Dim oValue = GetValueFromRow(oRow)
oValues.Add(oValue)
End If
@@ -123,6 +126,13 @@ Public Class frmLookupGrid
End If
End Sub
Private Function GetValueFromRow(pRow As DataRow) As String
If MultiSelect Then
Return pRow.Item(1)
Else
Return pRow.Item(0)
End If
End Function
Private Sub SyncItemsWithView(view As GridView)
' Wenn Vorbelegungen existieren, werden diese angehakt
@@ -145,8 +155,6 @@ Public Class frmLookupGrid
End If
End If
End If
Next
End If
End Sub
@@ -235,9 +243,15 @@ Public Class frmLookupGrid
End Sub
Private Sub viewLookup_ValidateRow(sender As Object, e As ValidateRowEventArgs) Handles viewLookup.ValidateRow
If MultiSelect And e.RowHandle = GridControl.NewItemRowHandle Then
Dim oRow As DataRowView = viewLookup.GetRow(e.RowHandle)
oRow.Row.Item("SELECTED") = True
If e.RowHandle = GridControl.NewItemRowHandle Then
Dim oRowView As DataRowView = viewLookup.GetRow(e.RowHandle)
Dim oValue = GetValueFromRow(oRowView.Row)
NewValues.Add(oValue)
' Automatically select newly added row when MultiSelect is enabled
If MultiSelect Then
oRowView.Row.Item(COLUMN_SELECTED) = True
End If
End If
End Sub
End Class

View File

@@ -187,10 +187,6 @@ Public Class ControlCreator
oControl.Properties.PreventDuplicates = pPreventDuplicateValues
oControl.Properties.AppearanceFocused.BackColor = HightlightColor
' Add Handler before assigning Default Value so
' OnControlChanged will fire for default values as well
AddHandler oControl.Properties.SelectedValuesChanged, Sub() OnControlChanged.Invoke(oControl)
If Not String.IsNullOrEmpty(pDefaultValue) Then
Dim oDefaultValues As New List(Of String)
@@ -208,6 +204,8 @@ Public Class ControlCreator
oControl.Properties.SelectedValues = oDefaultValues
End If
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

View File

@@ -29,8 +29,10 @@ Public Class frmLookup
LookupControl32.Properties.ValueMember = "Col1"
LookupControl32.Properties.DataSource = oTable
LookupControl33.Properties.AllowAddNewValues = True
LookupControl33.Properties.MultiSelect = True
LookupControl33.Properties.DataSource = oTable
End Sub
Private Function GetDatatable(Limit As Integer) As DataTable