diff --git a/Controls.LookupGrid/LookupControl.vbproj b/Controls.LookupGrid/LookupControl.vbproj index 9ebcc41b..42070850 100644 --- a/Controls.LookupGrid/LookupControl.vbproj +++ b/Controls.LookupGrid/LookupControl.vbproj @@ -151,6 +151,9 @@ LookupControl.vb + + LookupControl2.vb + VbMyResourcesResXFileCodeGenerator diff --git a/Controls.LookupGrid/LookupControl2.resx b/Controls.LookupGrid/LookupControl2.resx new file mode 100644 index 00000000..e5858cc2 --- /dev/null +++ b/Controls.LookupGrid/LookupControl2.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + False + + \ No newline at end of file diff --git a/Controls.LookupGrid/LookupControl2.vb b/Controls.LookupGrid/LookupControl2.vb index 54aa393d..95c502b4 100644 --- a/Controls.LookupGrid/LookupControl2.vb +++ b/Controls.LookupGrid/LookupControl2.vb @@ -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 diff --git a/Controls.LookupGrid/frmLookupGrid.Designer.vb b/Controls.LookupGrid/frmLookupGrid.Designer.vb index cc90e703..df89a0f1 100644 --- a/Controls.LookupGrid/frmLookupGrid.Designer.vb +++ b/Controls.LookupGrid/frmLookupGrid.Designer.vb @@ -69,6 +69,7 @@ Partial Class frmLookupGrid 'btnClear ' Me.btnClear.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.btnClear.DialogResult = System.Windows.Forms.DialogResult.OK Me.btnClear.Location = New System.Drawing.Point(236, 6) Me.btnClear.Name = "btnClear" Me.btnClear.Size = New System.Drawing.Size(136, 23) diff --git a/Controls.LookupGrid/frmLookupGrid.vb b/Controls.LookupGrid/frmLookupGrid.vb index 44517082..b186d83f 100644 --- a/Controls.LookupGrid/frmLookupGrid.vb +++ b/Controls.LookupGrid/frmLookupGrid.vb @@ -139,7 +139,7 @@ Public Class frmLookupGrid Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click SelectedValues = New List(Of String) - DialogResult = DialogResult.Cancel + DialogResult = DialogResult.OK Close() End Sub