diff --git a/DDMonorepo.sln b/DDMonorepo.sln index 157f3172..97d8cd8d 100644 --- a/DDMonorepo.sln +++ b/DDMonorepo.sln @@ -29,6 +29,10 @@ Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Variables", "Variables\Vari EndProject Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Config", "Config\Config.vbproj", "{44982F9B-6116-44E2-85D0-F39650B1EF99}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Controls", "Controls", "{F98C0329-C004-417F-B2AB-7466E88D8220}" +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "LookupGrid", "LookupGrid\LookupGrid.vbproj", "{3DCD6D1A-C830-4241-B7E4-27430E7EA483}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -71,6 +75,10 @@ Global {44982F9B-6116-44E2-85D0-F39650B1EF99}.Debug|Any CPU.Build.0 = Debug|Any CPU {44982F9B-6116-44E2-85D0-F39650B1EF99}.Release|Any CPU.ActiveCfg = Release|Any CPU {44982F9B-6116-44E2-85D0-F39650B1EF99}.Release|Any CPU.Build.0 = Release|Any CPU + {3DCD6D1A-C830-4241-B7E4-27430E7EA483}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3DCD6D1A-C830-4241-B7E4-27430E7EA483}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3DCD6D1A-C830-4241-B7E4-27430E7EA483}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3DCD6D1A-C830-4241-B7E4-27430E7EA483}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -85,6 +93,7 @@ Global {63B0EAA3-8BF5-46DA-9040-15E781F4C3B1} = {7AF3F9C2-C939-4A08-95C1-0453207E298A} {836C9ADE-E04E-4E1E-B17A-201E68014790} = {3E2008C8-27B1-41DD-9B1A-0C4029F6AECC} {44982F9B-6116-44E2-85D0-F39650B1EF99} = {3E2008C8-27B1-41DD-9B1A-0C4029F6AECC} + {3DCD6D1A-C830-4241-B7E4-27430E7EA483} = {F98C0329-C004-417F-B2AB-7466E88D8220} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C1BE4090-A0FD-48AF-86CB-39099D14B286} diff --git a/LookupGrid/LookupGrid.Designer.vb b/LookupGrid/LookupGrid.Designer.vb new file mode 100644 index 00000000..6c061d3a --- /dev/null +++ b/LookupGrid/LookupGrid.Designer.vb @@ -0,0 +1,61 @@ + _ +Partial Class LookupGrid + Inherits System.Windows.Forms.UserControl + + 'UserControl überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Wird vom Windows Form-Designer benötigt. + Private components As System.ComponentModel.IContainer + + 'Hinweis: Die folgende Prozedur ist für den Windows Form-Designer erforderlich. + 'Das Bearbeiten ist mit dem Windows Form-Designer möglich. + 'Das Bearbeiten mit dem Code-Editor ist nicht möglich. + _ + Private Sub InitializeComponent() + Me.TextBox1 = New System.Windows.Forms.TextBox() + Me.Button1 = New System.Windows.Forms.Button() + Me.SuspendLayout() + ' + 'TextBox1 + ' + Me.TextBox1.Location = New System.Drawing.Point(0, 0) + Me.TextBox1.Name = "TextBox1" + Me.TextBox1.Size = New System.Drawing.Size(231, 20) + Me.TextBox1.TabIndex = 0 + ' + 'Button1 + ' + Me.Button1.Location = New System.Drawing.Point(237, 0) + Me.Button1.Name = "Button1" + Me.Button1.Size = New System.Drawing.Size(56, 20) + Me.Button1.TabIndex = 1 + Me.Button1.Text = "Button1" + Me.Button1.UseVisualStyleBackColor = True + ' + 'LookupGrid + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.BackColor = System.Drawing.Color.Transparent + Me.Controls.Add(Me.Button1) + Me.Controls.Add(Me.TextBox1) + Me.Name = "LookupGrid" + Me.Size = New System.Drawing.Size(323, 57) + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + + Friend WithEvents TextBox1 As Windows.Forms.TextBox + Friend WithEvents Button1 As Windows.Forms.Button +End Class diff --git a/LookupGrid/LookupGrid.resx b/LookupGrid/LookupGrid.resx new file mode 100644 index 00000000..1af7de15 --- /dev/null +++ b/LookupGrid/LookupGrid.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file diff --git a/LookupGrid/LookupGrid.vb b/LookupGrid/LookupGrid.vb new file mode 100644 index 00000000..e76185d5 --- /dev/null +++ b/LookupGrid/LookupGrid.vb @@ -0,0 +1,4 @@ + +Public Class LookupGrid + +End Class diff --git a/LookupGrid/LookupGrid.vbproj b/LookupGrid/LookupGrid.vbproj new file mode 100644 index 00000000..5533a8e5 --- /dev/null +++ b/LookupGrid/LookupGrid.vbproj @@ -0,0 +1,174 @@ + + + + + Debug + AnyCPU + {3DCD6D1A-C830-4241-B7E4-27430E7EA483} + Library + LookupGrid + LookupGrid + 512 + Windows + v4.6.1 + + + true + full + true + true + bin\Debug\ + LookupGrid.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + LookupGrid.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + On + + + Binary + + + Off + + + On + + + + False + + + False + D:\ProgramFiles\DevExpress 18.1\Components\Bin\Framework\DevExpress.Office.v18.1.Core.dll + + + False + D:\ProgramFiles\DevExpress 18.1\Components\Bin\Framework\DevExpress.Pdf.v18.1.Core.dll + + + False + D:\ProgramFiles\DevExpress 18.1\Components\Bin\Framework\DevExpress.Printing.v18.1.Core.dll + + + False + D:\ProgramFiles\DevExpress 18.1\Components\Bin\Framework\DevExpress.RichEdit.v18.1.Core.dll + + + False + D:\ProgramFiles\DevExpress 18.1\Components\Bin\Framework\DevExpress.RichEdit.v18.1.Export.dll + + + + + + False + D:\ProgramFiles\DevExpress 18.1\Components\Bin\Framework\DevExpress.XtraLayout.v18.1.dll + + + False + D:\ProgramFiles\DevExpress 18.1\Components\Bin\Framework\DevExpress.XtraPrinting.v18.1.dll + + + + + + + + + + + + + + + + + + + + + + + + + frmLookupGrid.vb + + + Form + + + LookupGrid.vb + + + UserControl + + + + + LookupGridView.vb + + + Component + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + LookupGridControl.vb + + + Component + + + + + frmLookupGrid.vb + + + LookupGrid.vb + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + + + \ No newline at end of file diff --git a/LookupGrid/LookupGridControl.Designer.vb b/LookupGrid/LookupGridControl.Designer.vb new file mode 100644 index 00000000..441a84d1 --- /dev/null +++ b/LookupGrid/LookupGridControl.Designer.vb @@ -0,0 +1,47 @@ +Partial Class SimpleGridControl + Inherits System.ComponentModel.Component + + _ + Public Sub New(ByVal container As System.ComponentModel.IContainer) + MyClass.New() + + 'Erforderlich für die Unterstützung des Windows.Forms-Klassenkompositions-Designers + If (container IsNot Nothing) Then + container.Add(Me) + End If + + End Sub + + _ + Public Sub New() + MyBase.New() + + 'Dieser Aufruf ist für den Komponenten-Designer erforderlich. + InitializeComponent() + + End Sub + + 'Die Komponente überschreibt den Löschvorgang zum Bereinigen der Komponentenliste. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Wird vom Komponenten-Designer benötigt. + Private components As System.ComponentModel.IContainer + + 'Hinweis: Die folgende Prozedur ist für den Komponenten-Designer erforderlich. + 'Das Bearbeiten ist mit dem Komponenten-Designer möglich. + 'Das Bearbeiten mit dem Code-Editor ist nicht möglich. + _ + Private Sub InitializeComponent() + components = New System.ComponentModel.Container() + End Sub + +End Class diff --git a/LookupGrid/LookupGridControl.vb b/LookupGrid/LookupGridControl.vb new file mode 100644 index 00000000..c2a982bd --- /dev/null +++ b/LookupGrid/LookupGridControl.vb @@ -0,0 +1,18 @@ +Imports DevExpress.XtraGrid +Imports DevExpress.XtraGrid.Views.Base +Imports DevExpress.XtraGrid.Registrator + +Namespace LookupGrid + Public Class LookupGridControl + Inherits GridControl + + Protected Overrides Function CreateDefaultView() As BaseView + Return CreateView("LookupGridView") + End Function + Protected Overrides Sub RegisterAvailableViewsCore(ByVal collection As InfoCollection) + MyBase.RegisterAvailableViewsCore(collection) + collection.Add(New MyGridViewInfoRegistrator()) + End Sub + End Class +End Namespace + diff --git a/LookupGrid/LookupGridHandler.vb b/LookupGrid/LookupGridHandler.vb new file mode 100644 index 00000000..f3757b41 --- /dev/null +++ b/LookupGrid/LookupGridHandler.vb @@ -0,0 +1,19 @@ +Imports System.Windows.Forms +Imports DevExpress.XtraGrid.Views.Grid + +Namespace LookupGrid + Public Class LookupGridHandler + Inherits Handler.GridHandler + + Public Sub New(ByVal gridView As GridView) + MyBase.New(gridView) + End Sub + + Protected Overrides Sub OnKeyDown(ByVal e As KeyEventArgs) + MyBase.OnKeyDown(e) + If e.KeyData = Keys.Delete AndAlso View.State = GridState.Normal Then + View.DeleteRow(View.FocusedRowHandle) + End If + End Sub + End Class +End Namespace diff --git a/LookupGrid/LookupGridRegistration.vb b/LookupGrid/LookupGridRegistration.vb new file mode 100644 index 00000000..15f2ab79 --- /dev/null +++ b/LookupGrid/LookupGridRegistration.vb @@ -0,0 +1,24 @@ +Imports DevExpress.XtraGrid +Imports DevExpress.XtraGrid.Views.Base +Imports DevExpress.XtraGrid.Views.Base.Handler +Imports DevExpress.XtraGrid.Registrator + +Namespace LookupGrid + Public Class MyGridViewInfoRegistrator + Inherits GridInfoRegistrator + + Public Overrides ReadOnly Property ViewName() As String + Get + Return "LookupGridView" + End Get + End Property + Public Overrides Function CreateView(ByVal grid As GridControl) As BaseView + Return New LookupGridView(grid) + End Function + Public Overrides Function CreateHandler(ByVal view As BaseView) As BaseViewHandler + Return New LookupGridHandler(TryCast(view, LookupGridView)) + End Function + End Class + +End Namespace + diff --git a/LookupGrid/LookupGridView.Designer.vb b/LookupGrid/LookupGridView.Designer.vb new file mode 100644 index 00000000..0f90f5f5 --- /dev/null +++ b/LookupGrid/LookupGridView.Designer.vb @@ -0,0 +1,47 @@ +Partial Class LookupGridView + Inherits System.ComponentModel.Component + + _ + Public Sub New(ByVal container As System.ComponentModel.IContainer) + MyClass.New() + + 'Erforderlich für die Unterstützung des Windows.Forms-Klassenkompositions-Designers + If (container IsNot Nothing) Then + container.Add(Me) + End If + + End Sub + + _ + Public Sub New() + MyBase.New() + + 'Dieser Aufruf ist für den Komponenten-Designer erforderlich. + InitializeComponent() + + End Sub + + 'Die Komponente überschreibt den Löschvorgang zum Bereinigen der Komponentenliste. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Wird vom Komponenten-Designer benötigt. + Private components As System.ComponentModel.IContainer + + 'Hinweis: Die folgende Prozedur ist für den Komponenten-Designer erforderlich. + 'Das Bearbeiten ist mit dem Komponenten-Designer möglich. + 'Das Bearbeiten mit dem Code-Editor ist nicht möglich. + _ + Private Sub InitializeComponent() + components = New System.ComponentModel.Container() + End Sub + +End Class diff --git a/LookupGrid/LookupGridView.vb b/LookupGrid/LookupGridView.vb new file mode 100644 index 00000000..0f617a6d --- /dev/null +++ b/LookupGrid/LookupGridView.vb @@ -0,0 +1,55 @@ +Imports DevExpress.Data.Helpers +Imports DevExpress.Data.Filtering +Imports DevExpress.XtraGrid.Views.Base +Imports System.Reflection + +Namespace LookupGrid + Public Class LookupGridView + Inherits DevExpress.XtraGrid.Views.Grid.GridView + + Private _simpleSearch As Boolean + Public Sub New() + Me.New(Nothing) + End Sub + Public Property SimpleSearch() As Boolean + Get + Return _simpleSearch + End Get + Set(ByVal value As Boolean) + _simpleSearch = value + End Set + End Property + + Public Sub New(ByVal grid As DevExpress.XtraGrid.GridControl) + MyBase.New(grid) + ' put your initialization code here + End Sub + Protected Overrides ReadOnly Property ViewName() As String + Get + Return "LookupGridView" + End Get + End Property + Protected Overrides Function ConvertGridFilterToDataFilter(ByVal criteria As CriteriaOperator) As CriteriaOperator + Dim originalFindFilterText As String = Convert.ToString(GetType(ColumnView).InvokeMember("findFilterText", BindingFlags.Instance Or BindingFlags.NonPublic Or BindingFlags.GetField, Nothing, Me, New Object() {})) + If SimpleSearch Then + If Not (String.IsNullOrEmpty(originalFindFilterText)) Then + GetType(ColumnView).InvokeMember("findFilterText", BindingFlags.Instance Or BindingFlags.NonPublic Or BindingFlags.SetField, Nothing, Me, New Object() {String.Concat("""", originalFindFilterText, """")}) + End If + Dim findCriteria As CriteriaOperator = Nothing + Dim _lastParserResults As FindSearchParserResults = Nothing + If Not (String.IsNullOrEmpty(FindFilterText)) Then + _lastParserResults = (New FindSearchParser()).Parse(FindFilterText, GetFindToColumnsCollection()) + GetType(ColumnView).GetField("lastParserResults", BindingFlags.NonPublic Or BindingFlags.Instance).SetValue(Me, _lastParserResults) + If Not IsServerMode Then + _lastParserResults.AppendColumnFieldPrefixes() + End If + findCriteria = DxFtsContainsHelperAlt.Create(_lastParserResults, FilterCondition.Contains, IsServerMode) + End If + GetType(ColumnView).InvokeMember("findFilterText", BindingFlags.Instance Or BindingFlags.NonPublic Or BindingFlags.SetField, Nothing, Me, New Object() {originalFindFilterText}) + Return criteria And findCriteria + End If + Return MyBase.ConvertGridFilterToDataFilter(criteria) + End Function + End Class + +End Namespace \ No newline at end of file diff --git a/LookupGrid/My Project/Application.Designer.vb b/LookupGrid/My Project/Application.Designer.vb new file mode 100644 index 00000000..88dd01c7 --- /dev/null +++ b/LookupGrid/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + diff --git a/LookupGrid/My Project/Application.myapp b/LookupGrid/My Project/Application.myapp new file mode 100644 index 00000000..758895de --- /dev/null +++ b/LookupGrid/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 1 + true + diff --git a/LookupGrid/My Project/AssemblyInfo.vb b/LookupGrid/My Project/AssemblyInfo.vb new file mode 100644 index 00000000..797bea3e --- /dev/null +++ b/LookupGrid/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' Allgemeine Informationen über eine Assembly werden über die folgenden +' Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, +' die einer Assembly zugeordnet sind. + +' Werte der Assemblyattribute überprüfen + + + + + + + + + + +'Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird. + + +' Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +' +' Hauptversion +' Nebenversion +' Buildnummer +' Revision +' +' Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, +' übernehmen, indem Sie "*" eingeben: +' + + + diff --git a/LookupGrid/My Project/Resources.Designer.vb b/LookupGrid/My Project/Resources.Designer.vb new file mode 100644 index 00000000..6c546ba6 --- /dev/null +++ b/LookupGrid/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My.Resources + + 'This class was auto-generated by the StronglyTypedResourceBuilder + 'class via a tool like ResGen or Visual Studio. + 'To add or remove a member, edit your .ResX file then rerun ResGen + 'with the /str option, or rebuild your VS project. + ''' + ''' A strongly-typed resource class, for looking up localized strings, etc. + ''' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ''' + ''' Returns the cached ResourceManager instance used by this class. + ''' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("LookupGrid.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' Overrides the current thread's CurrentUICulture property for all + ''' resource lookups using this strongly typed resource class. + ''' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set(ByVal value As Global.System.Globalization.CultureInfo) + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/LookupGrid/My Project/Resources.resx b/LookupGrid/My Project/Resources.resx new file mode 100644 index 00000000..af7dbebb --- /dev/null +++ b/LookupGrid/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/LookupGrid/My Project/Settings.Designer.vb b/LookupGrid/My Project/Settings.Designer.vb new file mode 100644 index 00000000..127f3b1e --- /dev/null +++ b/LookupGrid/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings) + +#Region "My.Settings Auto-Save Functionality" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.LookupGrid.My.MySettings + Get + Return Global.LookupGrid.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/LookupGrid/My Project/Settings.settings b/LookupGrid/My Project/Settings.settings new file mode 100644 index 00000000..85b890b3 --- /dev/null +++ b/LookupGrid/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/LookupGrid/My Project/licenses.licx b/LookupGrid/My Project/licenses.licx new file mode 100644 index 00000000..824a99fc --- /dev/null +++ b/LookupGrid/My Project/licenses.licx @@ -0,0 +1 @@ +DevExpress.XtraGrid.GridControl, DevExpress.XtraGrid.v18.1, Version=18.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a diff --git a/LookupGrid/frmLookupGrid.Designer.vb b/LookupGrid/frmLookupGrid.Designer.vb new file mode 100644 index 00000000..af785cbf --- /dev/null +++ b/LookupGrid/frmLookupGrid.Designer.vb @@ -0,0 +1,103 @@ + _ +Partial Class frmLookupGrid + Inherits System.Windows.Forms.Form + + 'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Wird vom Windows Form-Designer benötigt. + Private components As System.ComponentModel.IContainer + + 'Hinweis: Die folgende Prozedur ist für den Windows Form-Designer erforderlich. + 'Das Bearbeiten ist mit dem Windows Form-Designer möglich. + 'Das Bearbeiten mit dem Code-Editor ist nicht möglich. + _ + Private Sub InitializeComponent() + Me.gridLookup = New DevExpress.XtraGrid.GridControl() + Me.viewLookup = New DevExpress.XtraGrid.Views.Grid.GridView() + Me.Panel1 = New System.Windows.Forms.Panel() + Me.btnOK = New System.Windows.Forms.Button() + Me.btnClear = New System.Windows.Forms.Button() + CType(Me.gridLookup, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.viewLookup, System.ComponentModel.ISupportInitialize).BeginInit() + Me.Panel1.SuspendLayout() + Me.SuspendLayout() + ' + 'gridLookup + ' + Me.gridLookup.Dock = System.Windows.Forms.DockStyle.Fill + Me.gridLookup.Location = New System.Drawing.Point(0, 0) + Me.gridLookup.MainView = Me.viewLookup + Me.gridLookup.Name = "gridLookup" + Me.gridLookup.Size = New System.Drawing.Size(384, 221) + Me.gridLookup.TabIndex = 0 + Me.gridLookup.ViewCollection.AddRange(New DevExpress.XtraGrid.Views.Base.BaseView() {Me.viewLookup}) + ' + 'viewLookup + ' + Me.viewLookup.GridControl = Me.gridLookup + Me.viewLookup.Name = "viewLookup" + ' + 'Panel1 + ' + Me.Panel1.Controls.Add(Me.btnOK) + Me.Panel1.Controls.Add(Me.btnClear) + Me.Panel1.Dock = System.Windows.Forms.DockStyle.Bottom + Me.Panel1.Location = New System.Drawing.Point(0, 221) + Me.Panel1.Name = "Panel1" + Me.Panel1.Size = New System.Drawing.Size(384, 40) + Me.Panel1.TabIndex = 1 + ' + 'btnOK + ' + Me.btnOK.Location = New System.Drawing.Point(12, 6) + Me.btnOK.Name = "btnOK" + Me.btnOK.Size = New System.Drawing.Size(117, 23) + Me.btnOK.TabIndex = 0 + Me.btnOK.Text = "OK" + Me.btnOK.UseVisualStyleBackColor = True + ' + 'btnClear + ' + Me.btnClear.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.btnClear.Location = New System.Drawing.Point(236, 6) + Me.btnClear.Name = "btnClear" + Me.btnClear.Size = New System.Drawing.Size(136, 23) + Me.btnClear.TabIndex = 0 + Me.btnClear.Text = "Leeren" + Me.btnClear.UseVisualStyleBackColor = True + ' + 'frmLookupGrid + ' + Me.AcceptButton = Me.btnOK + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(384, 261) + Me.Controls.Add(Me.gridLookup) + Me.Controls.Add(Me.Panel1) + Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow + Me.MinimumSize = New System.Drawing.Size(400, 300) + Me.Name = "frmLookupGrid" + Me.Text = "frmLookupGrid" + CType(Me.gridLookup, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.viewLookup, System.ComponentModel.ISupportInitialize).EndInit() + Me.Panel1.ResumeLayout(False) + Me.ResumeLayout(False) + + End Sub + + Friend WithEvents gridLookup As DevExpress.XtraGrid.GridControl + Friend WithEvents viewLookup As DevExpress.XtraGrid.Views.Grid.GridView + Friend WithEvents Panel1 As Windows.Forms.Panel + Friend WithEvents btnOK As Windows.Forms.Button + Friend WithEvents btnClear As Windows.Forms.Button +End Class diff --git a/LookupGrid/frmLookupGrid.resx b/LookupGrid/frmLookupGrid.resx new file mode 100644 index 00000000..1af7de15 --- /dev/null +++ b/LookupGrid/frmLookupGrid.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file diff --git a/LookupGrid/frmLookupGrid.vb b/LookupGrid/frmLookupGrid.vb new file mode 100644 index 00000000..0eb654b3 --- /dev/null +++ b/LookupGrid/frmLookupGrid.vb @@ -0,0 +1,151 @@ +Imports System.Windows.Forms +Imports DevExpress.XtraGrid +Imports DevExpress.XtraGrid.Views.Grid + +Public Class frmLookupGrid + Public Property MultiSelect As Boolean + Public Property AddNewValues As Boolean + Public Property PreventDuplicates As Boolean + Public Property DataSource As DataTable + Public Property SelectedValues As List(Of Object) + + Private originalValues As List(Of Object) + Private dataColumn As Integer + + Private view As GridView + Private grid As GridControl + + Private Sub frmLookupGrid_Load(sender As Object, e As EventArgs) Handles Me.Load + view = viewLookup + grid = gridLookup + + ' Datasource setzen + grid.DataSource = DataSource + + ' Anzeige Eigeschaften setzen + view.OptionsFind.AlwaysVisible = True + view.OptionsSelection.MultiSelect = False + + If MultiSelect Then + ' Selected Spalte anpassen + Dim checkboxColumn = view.Columns.Item(0) + checkboxColumn.Caption = " " + checkboxColumn.MaxWidth = 10 + + Text = "Wählen Sie einen oder mehrere Werte:" + dataColumn = 1 + Else + Text = "Wählen Sie einen Wert:" + dataColumn = 0 + End If + + If AddNewValues Then + view.OptionsBehavior.AllowAddRows = DevExpress.Utils.DefaultBoolean.True + view.OptionsView.NewItemRowPosition = NewItemRowPosition.Top + Else + view.OptionsBehavior.AllowAddRows = DevExpress.Utils.DefaultBoolean.False + view.OptionsView.NewItemRowPosition = NewItemRowPosition.None + End If + + ' Wenn Selected Values nicht gesetzt ist, leere Liste anlegen + If SelectedValues Is Nothing Then + SelectedValues = New List(Of Object) + End If + + ' Ursprüngliche Werte zwischenspeichern + originalValues = SelectedValues + + ' Bereits ausgewählte Werte im grid auswählen + SyncItemsWithView(view) + + ' Focus auf Find panel setzen + view.ShowFindPanel() + End Sub + + Private Sub SyncItemsWithView(view As GridView) + ' Wenn Vorbelegungen existieren, werden diese angehakt + If SelectedValues.Count > 0 Then + For i = 0 To view.DataRowCount - 1 + Dim rowHandle = view.GetRowHandle(i) + Dim rowView As DataRowView = view.GetRow(rowHandle) + + If rowView IsNot Nothing Then + Dim row As DataRow = rowView.Row + Dim value = row.Item(dataColumn) + + If SelectedValues.Contains(value) Then + If MultiSelect Then + row.Item(0) = True + Else + view.SelectRow(rowHandle) + End If + End If + End If + Next + End If + End Sub + + Private Sub btnOK_Click(sender As Object, e As EventArgs) Handles btnOK.Click + ' Filter vor dem Auslesen entfernen, damit alle Werte erfasst werden + view.FindFilterText = String.Empty + + If MultiSelect Then + Dim values As New List(Of Object) + + For index = 0 To viewLookup.DataRowCount - 1 + Dim row As DataRow = view.GetDataRow(index) + Dim selected As Boolean = row.Item(0) + Dim value As Object = row.Item(1) + + If selected Then + values.Add(value) + End If + Next + + ' Doppelte Werte entfernen, wenn konfiguriert + If PreventDuplicates Then + values = values.Distinct().ToList() + End If + + SelectedValues = values + Else + Dim rowHandle As Integer = view.GetSelectedRows().ToList().First() + Dim row As DataRow = view.GetDataRow(rowHandle) + Dim value = row.Item(0) + + SelectedValues = New List(Of Object) From {value} + End If + End Sub + + Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click + SelectedValues.Clear() + End Sub + + Private Sub gridLookup_KeyUp(sender As Object, e As KeyEventArgs) Handles gridLookup.KeyUp + If e.KeyCode = Keys.Escape Then + Close() + End If + End Sub + + Private Sub viewLookup_CellValueChanging(sender As Object, e As Views.Base.CellValueChangedEventArgs) Handles viewLookup.CellValueChanging + + If e.RowHandle = GridControl.NewItemRowHandle Then + Exit Sub + End If + + Dim rowHandle = e.RowHandle + Dim column = e.Column + End Sub + + Private Sub viewLookup_ShowingEditor(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles viewLookup.ShowingEditor + Dim rowHandleIsNewItemRow = (view.FocusedRowHandle = GridControl.NewItemRowHandle) + Dim columnIsCheckboxColumn = view.FocusedColumn.FieldName = "SELECTED" + + ' Prevent editing of Data Column/allow editing for Checkbox Column and NewValue Row + If rowHandleIsNewItemRow Or columnIsCheckboxColumn Then + e.Cancel = False + Else + e.Cancel = True + End If + End Sub +End Class \ No newline at end of file