disable button instead of hiding, remove empty values before saving, update dialog result handling
This commit is contained in:
@@ -22,7 +22,6 @@ Public Class LookupControl2
|
||||
Return _SelectedValues
|
||||
End Get
|
||||
Set(value As List(Of String))
|
||||
_SelectedValues = value
|
||||
UpdateSelectedValues(value)
|
||||
End Set
|
||||
End Property
|
||||
@@ -31,19 +30,20 @@ Public Class LookupControl2
|
||||
Return _ReadOnly
|
||||
End Get
|
||||
Set(value As Boolean)
|
||||
SetButtonVisibility(Not value)
|
||||
SetFormButtonEnabled(Not value)
|
||||
_ReadOnly = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private ReadOnly _LookupFormButton As EditorButton
|
||||
|
||||
Private Const TAG_DROPDOWN = "openDropdown"
|
||||
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)
|
||||
Private _SelectedValues As New List(Of String)
|
||||
Private _ReadOnly As Boolean = False
|
||||
|
||||
Shared Sub New()
|
||||
@@ -60,6 +60,7 @@ Public Class LookupControl2
|
||||
.Tag = TAG_BUTTON_LOOKUP_FORM
|
||||
}
|
||||
|
||||
Properties.Buttons.Item(0).Tag = TAG_DROPDOWN
|
||||
Properties.Buttons.AddRange({_LookupFormButton})
|
||||
|
||||
AddHandler ButtonClick, AddressOf HandleButtonClick
|
||||
@@ -67,13 +68,23 @@ Public Class LookupControl2
|
||||
AddHandler QueryPopUp, AddressOf HandleQueryPopup
|
||||
End Sub
|
||||
|
||||
Private Sub SetButtonVisibility(Visible As Boolean)
|
||||
Private Sub SetFormButtonEnabled(Enabled As Boolean)
|
||||
Dim oButton As EditorButton = Properties.Buttons.
|
||||
Where(Function(b) b.Tag = TAG_BUTTON_LOOKUP_FORM).
|
||||
FirstOrDefault()
|
||||
|
||||
If oButton IsNot Nothing Then
|
||||
oButton.Visible = Visible
|
||||
oButton.Enabled = Enabled
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub SetDropdownButtonEnabled(Enabled As Boolean)
|
||||
Dim oButton As EditorButton = Properties.Buttons.
|
||||
Where(Function(b) b.Tag = TAG_DROPDOWN).
|
||||
FirstOrDefault()
|
||||
|
||||
If oButton IsNot Nothing Then
|
||||
oButton.Enabled = Enabled
|
||||
End If
|
||||
End Sub
|
||||
|
||||
@@ -106,14 +117,7 @@ Public Class LookupControl2
|
||||
|
||||
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)
|
||||
SelectedValues = oValues
|
||||
End If
|
||||
End Using
|
||||
End Select
|
||||
@@ -124,6 +128,8 @@ Public Class LookupControl2
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Values.RemoveAll(Function(v) String.IsNullOrEmpty(v))
|
||||
|
||||
If MultiSelect = True Then
|
||||
Properties.DataSource = Values
|
||||
|
||||
@@ -140,6 +146,8 @@ Public Class LookupControl2
|
||||
Text = Values.FirstOrDefault()
|
||||
EditValue = Nothing
|
||||
End If
|
||||
|
||||
_SelectedValues = Values
|
||||
End Sub
|
||||
|
||||
Private Function GetLookupForm() As frmLookupGrid
|
||||
|
||||
Reference in New Issue
Block a user