132 lines
4.9 KiB
VB.net
132 lines
4.9 KiB
VB.net
Imports System.ComponentModel
|
|
Imports DevExpress.XtraEditors
|
|
Imports DevExpress.XtraEditors.Controls
|
|
Imports DevExpress.XtraEditors.Repository
|
|
|
|
Public Class GridLookupEditExOLD
|
|
Inherits GridLookUpEdit
|
|
|
|
<Category("Einstellungen"), Description("Gibt an, ob mehrere Werte auswählbar sind"), DefaultValue(False)>
|
|
Public Property MultiSelect As Boolean
|
|
<Category("Einstellungen"), Description("Gibt an, ob neue Werte hinzugefügt werden können"), DefaultValue(False)>
|
|
Public Property AllowAddNewValues As Boolean
|
|
<Category("Einstellungen"), Description("Gibt an, ob das Hinzufügen von identischen Werten erlaubt ist"), DefaultValue(False)>
|
|
Public Property PreventDuplicates As Boolean
|
|
|
|
Public Property DataSource As DataTable
|
|
|
|
Public Property SelectedValues As List(Of String)
|
|
Get
|
|
If _selectedValues Is Nothing Then
|
|
Return New List(Of String)
|
|
End If
|
|
|
|
Return _selectedValues
|
|
End Get
|
|
Set(value As List(Of String))
|
|
_selectedValues = value
|
|
|
|
UpdateSelectedValues(value)
|
|
End Set
|
|
End Property
|
|
|
|
Private _selectedValues As List(Of String)
|
|
|
|
Private Const TAG_BUTTON_LOOKUP_FORM = "openLookupForm"
|
|
Private Const TEXT_NO_RECORDS = "Keine Datensätze ausgewählt"
|
|
Friend WithEvents fProperties As RepositoryItemGridLookUpEdit
|
|
Friend WithEvents fPropertiesView As DevExpress.XtraGrid.Views.Grid.GridView
|
|
Private Const TEXT_N_RECORDS = "{0} Datensätze ausgewählt"
|
|
|
|
Public Sub New()
|
|
Properties.View.OptionsBehavior.ReadOnly = True
|
|
Properties.View.OptionsBehavior.Editable = False
|
|
Properties.View.OptionsView.ShowColumnHeaders = False
|
|
Properties.PopupFormSize = New System.Drawing.Size(Properties.PopupFormSize.Width, 100)
|
|
|
|
' If single select, remove dropdown button
|
|
If MultiSelect = False Then
|
|
Properties.Buttons.Clear()
|
|
End If
|
|
|
|
Properties.Buttons.Add(New EditorButton() With {
|
|
.Kind = ButtonPredefines.Ellipsis,
|
|
.Tag = TAG_BUTTON_LOOKUP_FORM
|
|
})
|
|
|
|
End Sub
|
|
|
|
Private Function GetLookupForm() As frmLookupGrid
|
|
Dim oForm As New frmLookupGrid() With {
|
|
.MultiSelect = MultiSelect,
|
|
.AddNewValues = AllowAddNewValues,
|
|
.PreventDuplicates = PreventDuplicates,
|
|
.DataSource = DataSource,
|
|
.SelectedValues = SelectedValues,
|
|
.StartPosition = Windows.Forms.FormStartPosition.Manual,
|
|
.Location = PointToScreen(New System.Drawing.Point(Width, 0))
|
|
}
|
|
|
|
Return oForm
|
|
End Function
|
|
|
|
Private Sub UpdateSelectedValues(Values As List(Of String))
|
|
If MultiSelect = True Then
|
|
Properties.DataSource = Values
|
|
Properties.NullText = IIf(Values.Count = 0, TEXT_NO_RECORDS, String.Format(TEXT_N_RECORDS, Values.Count))
|
|
Else
|
|
Text = Values.FirstOrDefault()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub GridLookupEditEx_EditValueChanging(sender As Object, e As ChangingEventArgs) Handles Me.EditValueChanging
|
|
If MultiSelect Then
|
|
e.Cancel = True
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub lookupControlMulti_ButtonClick(sender As Object, e As ButtonPressedEventArgs)
|
|
If e.Button.Tag <> TAG_BUTTON_LOOKUP_FORM Then
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim oForm As frmLookupGrid = GetLookupForm()
|
|
Dim oResult = oForm.ShowDialog()
|
|
|
|
If oResult = Windows.Forms.DialogResult.OK Then
|
|
Dim oValues = oForm.SelectedValues
|
|
|
|
UpdateSelectedValues(oValues)
|
|
|
|
SelectedValues = oValues
|
|
End If
|
|
|
|
oForm.Dispose()
|
|
End Sub
|
|
|
|
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
|