move LookupGrid to Controls.LookupGrid folder
This commit is contained in:
139
Controls.LookupGrid/LookupControl2.vb
Normal file
139
Controls.LookupGrid/LookupControl2.vb
Normal file
@@ -0,0 +1,139 @@
|
||||
Imports System.ComponentModel
|
||||
Imports System.Drawing
|
||||
Imports DevExpress.XtraEditors
|
||||
Imports DevExpress.XtraEditors.Drawing
|
||||
Imports DevExpress.XtraEditors.Registrator
|
||||
Imports DevExpress.XtraEditors.Repository
|
||||
Imports DevExpress.XtraEditors.ViewInfo
|
||||
Imports DevExpress.XtraEditors.Popup
|
||||
Imports DevExpress.Accessibility
|
||||
Imports DevExpress.XtraEditors.Controls
|
||||
|
||||
|
||||
|
||||
<UserRepositoryItem("RegisterLookupControl2")>
|
||||
Public Class RepositoryItemLookupControl2
|
||||
Inherits RepositoryItemGridLookUpEdit
|
||||
|
||||
Shared Sub New()
|
||||
RegisterLookupControl2()
|
||||
End Sub
|
||||
|
||||
Public Const CustomEditName As String = "LookupControl2"
|
||||
|
||||
Public Sub New()
|
||||
|
||||
End Sub
|
||||
|
||||
Public Overrides ReadOnly Property EditorTypeName As String
|
||||
Get
|
||||
Return CustomEditName
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Shared Sub RegisterLookupControl2()
|
||||
Dim img As Image = Nothing
|
||||
EditorRegistrationInfo.Default.Editors.Add(New EditorClassInfo(CustomEditName, GetType(LookupControl2), GetType(RepositoryItemLookupControl2), GetType(GridLookUpEditBaseViewInfo), New ButtonEditPainter(), True, img, GetType(ButtonEditAccessible)))
|
||||
End Sub
|
||||
|
||||
Public Overrides Sub Assign(item As RepositoryItem)
|
||||
BeginUpdate()
|
||||
Try
|
||||
MyBase.Assign(item)
|
||||
Dim source As RepositoryItemLookupControl2 = TryCast(item, RepositoryItemLookupControl2)
|
||||
If source Is Nothing Then
|
||||
Return
|
||||
End If
|
||||
Finally
|
||||
EndUpdate()
|
||||
End Try
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
<ToolboxItem(True)>
|
||||
Public Class LookupControl2
|
||||
Inherits GridLookUpEdit
|
||||
|
||||
Public Property MultiSelect As Boolean
|
||||
Public Property AllowAddNewValues As Boolean
|
||||
Public Property PreventDuplicates As Boolean
|
||||
Public Property DataSource As DataTable
|
||||
Public Property SelectedValues As List(Of String)
|
||||
|
||||
Private Const TAG_BUTTON_LOOKUP_FORM = "openLookupForm"
|
||||
Private Const TEXT_NO_RECORDS = "Keine Datensätze ausgewählt"
|
||||
Private Const TEXT_N_RECORDS = "{0} Datensätze ausgewählt"
|
||||
|
||||
Shared Sub New()
|
||||
RepositoryItemLookupControl2.RegisterLookupControl2()
|
||||
End Sub
|
||||
|
||||
Public Sub New()
|
||||
Properties.Buttons.Add(New EditorButton() With {
|
||||
.Kind = ButtonPredefines.Ellipsis,
|
||||
.Tag = TAG_BUTTON_LOOKUP_FORM
|
||||
})
|
||||
|
||||
AddHandler ButtonClick, AddressOf HandleButtonClick
|
||||
AddHandler EditValueChanging, AddressOf HandleEditValueChanging
|
||||
End Sub
|
||||
|
||||
Private Sub HandleEditValueChanging(sender As Object, e As ChangingEventArgs)
|
||||
e.Cancel = True
|
||||
End Sub
|
||||
|
||||
Private Sub HandleButtonClick(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 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 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 Point(Width, 0))
|
||||
}
|
||||
|
||||
Return oForm
|
||||
End Function
|
||||
|
||||
<DesignerSerializationVisibility(DesignerSerializationVisibility.Content)>
|
||||
Public Shadows ReadOnly Property Properties As RepositoryItemLookupControl2
|
||||
Get
|
||||
Return TryCast(MyBase.Properties, RepositoryItemLookupControl2)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Overrides ReadOnly Property EditorTypeName As String
|
||||
Get
|
||||
Return RepositoryItemLookupControl2.CustomEditName
|
||||
End Get
|
||||
End Property
|
||||
End Class
|
||||
Reference in New Issue
Block a user