Compare commits
3 Commits
5218782131
...
96f3ece84e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
96f3ece84e | ||
|
|
11908ab246 | ||
|
|
2450977fc3 |
@@ -229,6 +229,16 @@ Public Class RepositoryItemLookupControl3
|
|||||||
If oResult = Windows.Forms.DialogResult.OK Then
|
If oResult = Windows.Forms.DialogResult.OK Then
|
||||||
Dim oValues = oForm.SelectedValues
|
Dim oValues = oForm.SelectedValues
|
||||||
UpdateSelectedValues(oValues)
|
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 If
|
||||||
End Using
|
End Using
|
||||||
End If
|
End If
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ Public Class frmLookupGrid
|
|||||||
Public Property PreventDuplicates As Boolean
|
Public Property PreventDuplicates As Boolean
|
||||||
Public Property DataSource As DataTable
|
Public Property DataSource As DataTable
|
||||||
Public Property SelectedValues As List(Of String)
|
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 _DataColumn As Integer
|
||||||
Private _DataSourceTemp As DataTable
|
Private _DataSourceTemp As DataTable
|
||||||
@@ -29,7 +32,7 @@ Public Class frmLookupGrid
|
|||||||
End If
|
End If
|
||||||
|
|
||||||
If MultiSelect Then
|
If MultiSelect Then
|
||||||
If Not _DataSourceTemp.Columns.Contains("SELECTED") Then
|
If Not _DataSourceTemp.Columns.Contains(COLUMN_SELECTED) Then
|
||||||
Dim selectedColumn = New DataColumn() With {
|
Dim selectedColumn = New DataColumn() With {
|
||||||
.ColumnName = "SELECTED",
|
.ColumnName = "SELECTED",
|
||||||
.DataType = GetType(Boolean),
|
.DataType = GetType(Boolean),
|
||||||
@@ -96,7 +99,7 @@ Public Class frmLookupGrid
|
|||||||
For oIndex = 0 To viewLookup.DataRowCount - 1
|
For oIndex = 0 To viewLookup.DataRowCount - 1
|
||||||
Dim oRow As DataRow = _View.GetDataRow(oIndex)
|
Dim oRow As DataRow = _View.GetDataRow(oIndex)
|
||||||
Dim oSelected As Boolean = oRow.Item(0)
|
Dim oSelected As Boolean = oRow.Item(0)
|
||||||
Dim oValue As Object = oRow.Item(1)
|
Dim oValue As Object = GetValueFromRow(oRow)
|
||||||
|
|
||||||
If oSelected Then
|
If oSelected Then
|
||||||
oValues.Add(oValue)
|
oValues.Add(oValue)
|
||||||
@@ -115,7 +118,7 @@ Public Class frmLookupGrid
|
|||||||
Dim oValues As New List(Of String)
|
Dim oValues As New List(Of String)
|
||||||
|
|
||||||
If oRow IsNot Nothing Then
|
If oRow IsNot Nothing Then
|
||||||
Dim oValue = oRow.Item(0)
|
Dim oValue = GetValueFromRow(oRow)
|
||||||
oValues.Add(oValue)
|
oValues.Add(oValue)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
@@ -123,6 +126,13 @@ Public Class frmLookupGrid
|
|||||||
End If
|
End If
|
||||||
End Sub
|
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)
|
Private Sub SyncItemsWithView(view As GridView)
|
||||||
' Wenn Vorbelegungen existieren, werden diese angehakt
|
' Wenn Vorbelegungen existieren, werden diese angehakt
|
||||||
@@ -145,8 +155,6 @@ Public Class frmLookupGrid
|
|||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
|
||||||
Next
|
Next
|
||||||
End If
|
End If
|
||||||
End Sub
|
End Sub
|
||||||
@@ -235,9 +243,15 @@ Public Class frmLookupGrid
|
|||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub viewLookup_ValidateRow(sender As Object, e As ValidateRowEventArgs) Handles viewLookup.ValidateRow
|
Private Sub viewLookup_ValidateRow(sender As Object, e As ValidateRowEventArgs) Handles viewLookup.ValidateRow
|
||||||
If MultiSelect And e.RowHandle = GridControl.NewItemRowHandle Then
|
If e.RowHandle = GridControl.NewItemRowHandle Then
|
||||||
Dim oRow As DataRowView = viewLookup.GetRow(e.RowHandle)
|
Dim oRowView As DataRowView = viewLookup.GetRow(e.RowHandle)
|
||||||
oRow.Row.Item("SELECTED") = True
|
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 If
|
||||||
End Sub
|
End Sub
|
||||||
End Class
|
End Class
|
||||||
@@ -187,10 +187,6 @@ Public Class ControlCreator
|
|||||||
oControl.Properties.PreventDuplicates = pPreventDuplicateValues
|
oControl.Properties.PreventDuplicates = pPreventDuplicateValues
|
||||||
oControl.Properties.AppearanceFocused.BackColor = HightlightColor
|
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
|
If Not String.IsNullOrEmpty(pDefaultValue) Then
|
||||||
Dim oDefaultValues As New List(Of String)
|
Dim oDefaultValues As New List(Of String)
|
||||||
|
|
||||||
@@ -208,6 +204,8 @@ Public Class ControlCreator
|
|||||||
oControl.Properties.SelectedValues = oDefaultValues
|
oControl.Properties.SelectedValues = oDefaultValues
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
AddHandler oControl.Properties.SelectedValuesChanged, Sub() OnControlChanged.Invoke(oControl)
|
||||||
|
|
||||||
If OnLookupData Is Nothing Then
|
If OnLookupData Is Nothing Then
|
||||||
Logger.Warn("LookupGrid Datasource could not be set, OnLookupData Function is not defined!")
|
Logger.Warn("LookupGrid Datasource could not be set, OnLookupData Function is not defined!")
|
||||||
End If
|
End If
|
||||||
|
|||||||
@@ -29,8 +29,10 @@ Public Class frmLookup
|
|||||||
LookupControl32.Properties.ValueMember = "Col1"
|
LookupControl32.Properties.ValueMember = "Col1"
|
||||||
LookupControl32.Properties.DataSource = oTable
|
LookupControl32.Properties.DataSource = oTable
|
||||||
|
|
||||||
|
|
||||||
LookupControl33.Properties.AllowAddNewValues = True
|
LookupControl33.Properties.AllowAddNewValues = True
|
||||||
LookupControl33.Properties.MultiSelect = True
|
LookupControl33.Properties.MultiSelect = True
|
||||||
|
LookupControl33.Properties.DataSource = oTable
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Function GetDatatable(Limit As Integer) As DataTable
|
Private Function GetDatatable(Limit As Integer) As DataTable
|
||||||
|
|||||||
Reference in New Issue
Block a user