lots of bugfixing for lookupgrid
This commit is contained in:
@@ -21,10 +21,6 @@ Public Class RepositoryItemLookupControl2
|
||||
|
||||
Public Const CustomEditName As String = "LookupControl2"
|
||||
|
||||
Public Sub New()
|
||||
|
||||
End Sub
|
||||
|
||||
Public Overrides ReadOnly Property EditorTypeName As String
|
||||
Get
|
||||
Return CustomEditName
|
||||
@@ -59,54 +55,110 @@ Public Class LookupControl2
|
||||
Public Property PreventDuplicates As Boolean
|
||||
Public Property DataSource As DataTable
|
||||
Public Property SelectedValues As List(Of String)
|
||||
Get
|
||||
Return _SelectedValues
|
||||
End Get
|
||||
Set(value As List(Of String))
|
||||
_SelectedValues = value
|
||||
UpdateSelectedValues(value)
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private LookupFormButton As EditorButton
|
||||
Private DropdownButton As EditorButton
|
||||
|
||||
Private Const TAG_BUTTON_LOOKUP_FORM = "openLookupForm"
|
||||
|
||||
Private Const TEXT_NO_RECORDS = "Keine Datensätze ausgewählt"
|
||||
Private Const TEXT_ONE_RECORD = "Ein Datensatz ausgewählt"
|
||||
Private Const TEXT_N_RECORDS = "{0} Datensätze ausgewählt"
|
||||
|
||||
Private _SelectedValues As List(Of String)
|
||||
|
||||
Shared Sub New()
|
||||
RepositoryItemLookupControl2.RegisterLookupControl2()
|
||||
End Sub
|
||||
|
||||
Public Sub New()
|
||||
Properties.Buttons.Add(New EditorButton() With {
|
||||
MyClass.New(MultiSelect:=False)
|
||||
End Sub
|
||||
|
||||
Public Sub New(MultiSelect As Boolean)
|
||||
LookupFormButton = New EditorButton() With {
|
||||
.Kind = ButtonPredefines.Ellipsis,
|
||||
.Tag = TAG_BUTTON_LOOKUP_FORM
|
||||
})
|
||||
}
|
||||
|
||||
Properties.Buttons.AddRange({LookupFormButton})
|
||||
|
||||
AddHandler ButtonClick, AddressOf HandleButtonClick
|
||||
AddHandler EditValueChanging, AddressOf HandleEditValueChanging
|
||||
AddHandler QueryPopUp, AddressOf HandleQueryPopup
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Prevents popup from opening when multiselect is false
|
||||
''' </summary>
|
||||
Private Sub HandleQueryPopup(sender As Object, e As CancelEventArgs)
|
||||
If MultiSelect = False Then
|
||||
e.Cancel = True
|
||||
End If
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Prevents Editvalue changing when multiselect is true
|
||||
''' </summary>
|
||||
Private Sub HandleEditValueChanging(sender As Object, e As ChangingEventArgs)
|
||||
e.Cancel = True
|
||||
If MultiSelect Then
|
||||
e.Cancel = True
|
||||
End If
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Handles opening frmLookup when ellipsis button is clicked
|
||||
''' </summary>
|
||||
Private Sub HandleButtonClick(sender As Object, e As ButtonPressedEventArgs)
|
||||
If e.Button.Tag <> TAG_BUTTON_LOOKUP_FORM Then
|
||||
Exit Sub
|
||||
End If
|
||||
Select Case e.Button.Tag
|
||||
Case TAG_BUTTON_LOOKUP_FORM
|
||||
Dim oForm As frmLookupGrid = GetLookupForm()
|
||||
Dim oResult = oForm.ShowDialog()
|
||||
|
||||
Dim oForm As frmLookupGrid = GetLookupForm()
|
||||
Dim oResult = oForm.ShowDialog()
|
||||
If oResult = Windows.Forms.DialogResult.OK Then
|
||||
Dim oValues = oForm.SelectedValues
|
||||
|
||||
If oResult = Windows.Forms.DialogResult.OK Then
|
||||
Dim oValues = oForm.SelectedValues
|
||||
UpdateSelectedValues(oValues)
|
||||
SelectedValues = oValues
|
||||
ElseIf oResult = Windows.Forms.DialogResult.Cancel Then
|
||||
Dim oValues = New List(Of String)
|
||||
|
||||
UpdateSelectedValues(oValues)
|
||||
UpdateSelectedValues(oValues)
|
||||
SelectedValues = oValues
|
||||
End If
|
||||
|
||||
SelectedValues = oValues
|
||||
End If
|
||||
|
||||
oForm.Dispose()
|
||||
oForm.Dispose()
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
Private Sub UpdateSelectedValues(Values As List(Of String))
|
||||
If Values Is Nothing Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
If MultiSelect = True Then
|
||||
Properties.DataSource = Values
|
||||
Properties.NullText = IIf(Values.Count = 0, TEXT_NO_RECORDS, String.Format(TEXT_N_RECORDS, Values.Count))
|
||||
|
||||
Select Case Values.Count
|
||||
Case 0
|
||||
Properties.NullText = TEXT_NO_RECORDS
|
||||
Case 1
|
||||
Properties.NullText = TEXT_ONE_RECORD
|
||||
Case Else
|
||||
Properties.NullText = String.Format(TEXT_N_RECORDS, Values.Count)
|
||||
End Select
|
||||
Else
|
||||
Properties.NullText = Values.FirstOrDefault()
|
||||
Text = Values.FirstOrDefault()
|
||||
EditValue = Nothing
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
|
||||
' übernehmen, indem Sie "*" eingeben:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("1.0.0.0")>
|
||||
<Assembly: AssemblyVersion("0.0.1.0")>
|
||||
<Assembly: AssemblyFileVersion("1.0.0.0")>
|
||||
|
||||
@@ -17,6 +17,7 @@ Public Class frmLookupGrid
|
||||
view = viewLookup
|
||||
grid = gridLookup
|
||||
|
||||
|
||||
If DataSource Is Nothing Then
|
||||
Exit Sub
|
||||
End If
|
||||
@@ -136,7 +137,7 @@ Public Class frmLookupGrid
|
||||
End Sub
|
||||
|
||||
Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
|
||||
SelectedValues.Clear()
|
||||
SelectedValues = New List(Of String)
|
||||
|
||||
DialogResult = DialogResult.Cancel
|
||||
Close()
|
||||
|
||||
Reference in New Issue
Block a user