This commit is contained in:
Digital Data - Marlon Schreiber
2019-05-23 11:31:24 +02:00
9 changed files with 280 additions and 71 deletions

View File

@@ -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,21 +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)
Friend WithEvents fProperties As RepositoryItemGridLookUpEdit
Friend WithEvents fPropertiesView As DevExpress.XtraGrid.Views.Grid.GridView
Private _SelectedValues As New List(Of String)
Private _ReadOnly As Boolean = False
Shared Sub New()
@@ -62,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
@@ -69,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
@@ -108,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
@@ -126,6 +128,8 @@ Public Class LookupControl2
Exit Sub
End If
Values.RemoveAll(Function(v) String.IsNullOrEmpty(v))
If MultiSelect = True Then
Properties.DataSource = Values
@@ -142,6 +146,8 @@ Public Class LookupControl2
Text = Values.FirstOrDefault()
EditValue = Nothing
End If
_SelectedValues = Values
End Sub
Private Function GetLookupForm() As frmLookupGrid
@@ -170,31 +176,6 @@ Public Class LookupControl2
Return RepositoryItemLookupControl2.CustomEditName
End Get
End Property
Private Sub InitializeComponent()
Me.fProperties = New DevExpress.XtraEditors.Repository.RepositoryItemGridLookUpEdit()
Me.fPropertiesView = New DevExpress.XtraGrid.Views.Grid.GridView()
CType(Me.fProperties, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.fPropertiesView, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'fProperties
'
Me.fProperties.Buttons.AddRange(New DevExpress.XtraEditors.Controls.EditorButton() {New DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)})
Me.fProperties.Name = "fProperties"
Me.fProperties.PopupView = Me.fPropertiesView
'
'fPropertiesView
'
Me.fPropertiesView.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus
Me.fPropertiesView.Name = "fPropertiesView"
Me.fPropertiesView.OptionsSelection.EnableAppearanceFocusedCell = False
Me.fPropertiesView.OptionsView.ShowGroupPanel = False
CType(Me.fProperties, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.fPropertiesView, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
End Class
<UserRepositoryItem("RegisterLookupControl2")>

View File

@@ -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)

View File

@@ -140,7 +140,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