jj: first usable version of lookup grid
This commit is contained in:
33
LookupGrid/Grid.Designer.vb
generated
33
LookupGrid/Grid.Designer.vb
generated
@@ -1,9 +1,9 @@
|
||||
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
|
||||
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()>
|
||||
Partial Class Grid
|
||||
Inherits System.Windows.Forms.UserControl
|
||||
|
||||
'UserControl überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen.
|
||||
<System.Diagnostics.DebuggerNonUserCode()> _
|
||||
<System.Diagnostics.DebuggerNonUserCode()>
|
||||
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
|
||||
Try
|
||||
If disposing AndAlso components IsNot Nothing Then
|
||||
@@ -20,10 +20,10 @@ Partial Class Grid
|
||||
'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.
|
||||
<System.Diagnostics.DebuggerStepThrough()> _
|
||||
<System.Diagnostics.DebuggerStepThrough()>
|
||||
Private Sub InitializeComponent()
|
||||
Me.TextBox1 = New System.Windows.Forms.TextBox()
|
||||
Me.Button1 = New System.Windows.Forms.Button()
|
||||
Me.btnOpenForm = New System.Windows.Forms.Button()
|
||||
Me.SuspendLayout()
|
||||
'
|
||||
'TextBox1
|
||||
@@ -33,29 +33,30 @@ Partial Class Grid
|
||||
Me.TextBox1.Size = New System.Drawing.Size(231, 20)
|
||||
Me.TextBox1.TabIndex = 0
|
||||
'
|
||||
'Button1
|
||||
'btnOpenForm
|
||||
'
|
||||
Me.Button1.Location = New System.Drawing.Point(237, 0)
|
||||
Me.Button1.Name = "Button1"
|
||||
Me.Button1.Size = New System.Drawing.Size(37, 20)
|
||||
Me.Button1.TabIndex = 1
|
||||
Me.Button1.Text = "Button1"
|
||||
Me.Button1.UseVisualStyleBackColor = True
|
||||
Me.btnOpenForm.Location = New System.Drawing.Point(237, 0)
|
||||
Me.btnOpenForm.Name = "btnOpenForm"
|
||||
Me.btnOpenForm.Size = New System.Drawing.Size(30, 20)
|
||||
Me.btnOpenForm.TabIndex = 1
|
||||
Me.btnOpenForm.Text = "..."
|
||||
Me.btnOpenForm.UseVisualStyleBackColor = True
|
||||
'
|
||||
'LookupGrid
|
||||
'Grid
|
||||
'
|
||||
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
|
||||
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
|
||||
Me.AutoSize = True
|
||||
Me.BackColor = System.Drawing.Color.Transparent
|
||||
Me.Controls.Add(Me.Button1)
|
||||
Me.Controls.Add(Me.btnOpenForm)
|
||||
Me.Controls.Add(Me.TextBox1)
|
||||
Me.Name = "LookupGrid"
|
||||
Me.Size = New System.Drawing.Size(323, 57)
|
||||
Me.Name = "Grid"
|
||||
Me.Size = New System.Drawing.Size(270, 23)
|
||||
Me.ResumeLayout(False)
|
||||
Me.PerformLayout()
|
||||
|
||||
End Sub
|
||||
|
||||
Friend WithEvents TextBox1 As Windows.Forms.TextBox
|
||||
Friend WithEvents Button1 As Windows.Forms.Button
|
||||
Friend WithEvents btnOpenForm As Windows.Forms.Button
|
||||
End Class
|
||||
|
||||
@@ -1,7 +1,28 @@
|
||||
|
||||
Public Class Grid
|
||||
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
|
||||
Imports System.ComponentModel
|
||||
|
||||
Public Class Grid
|
||||
<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
|
||||
<Browsable(False)>
|
||||
Public Property DataSource As DataTable
|
||||
<Browsable(False)>
|
||||
Public Property SelectedValues As New List(Of Object)
|
||||
|
||||
Private Sub btnOpenForm_Click(sender As Object, e As EventArgs) Handles btnOpenForm.Click
|
||||
Dim frm As New frmLookupGrid() With {
|
||||
.MultiSelect = MultiSelect,
|
||||
.AddNewValues = AllowAddNewValues,
|
||||
.PreventDuplicates = PreventDuplicates,
|
||||
.DataSource = DataSource,
|
||||
.SelectedValues = SelectedValues
|
||||
}
|
||||
|
||||
frm.ShowDialog()
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
|
||||
@@ -2,16 +2,17 @@
|
||||
Imports DevExpress.XtraGrid.Views.Base
|
||||
Imports DevExpress.XtraGrid.Registrator
|
||||
|
||||
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 GridViewInfoRegistrator())
|
||||
End Sub
|
||||
End Class
|
||||
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 GridViewInfoRegistrator())
|
||||
End Sub
|
||||
End Class
|
||||
End Namespace
|
||||
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
Imports System.Windows.Forms
|
||||
Imports DevExpress.XtraGrid.Views.Grid
|
||||
|
||||
Namespace LookupGrid
|
||||
Public Class GridHandler
|
||||
Inherits Handler.GridHandler
|
||||
|
||||
Public Class GridHandler
|
||||
Inherits Handler.GridHandler
|
||||
Public Sub New(ByVal gridView As GridView)
|
||||
MyBase.New(gridView)
|
||||
End Sub
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
@@ -3,7 +3,8 @@ Imports DevExpress.XtraGrid.Views.Base
|
||||
Imports DevExpress.XtraGrid.Views.Base.Handler
|
||||
Imports DevExpress.XtraGrid.Registrator
|
||||
|
||||
Public Class GridViewInfoRegistrator
|
||||
Namespace LookupGrid
|
||||
Public Class GridViewInfoRegistrator
|
||||
Inherits GridInfoRegistrator
|
||||
|
||||
Public Overrides ReadOnly Property ViewName() As String
|
||||
@@ -12,7 +13,7 @@ Public Class GridViewInfoRegistrator
|
||||
End Get
|
||||
End Property
|
||||
Public Overrides Function CreateView(ByVal grid As GridControl) As BaseView
|
||||
Return New LookupGridView(grid)
|
||||
Return New LookupGridView(TryCast(grid, GridControl))
|
||||
End Function
|
||||
Public Overrides Function CreateHandler(ByVal view As BaseView) As BaseViewHandler
|
||||
Return New GridHandler(TryCast(view, LookupGridView))
|
||||
@@ -20,3 +21,6 @@ Public Class GridViewInfoRegistrator
|
||||
End Class
|
||||
|
||||
|
||||
|
||||
End Namespace
|
||||
|
||||
|
||||
8
LookupGrid/GridView.Designer.vb
generated
8
LookupGrid/GridView.Designer.vb
generated
@@ -1,7 +1,7 @@
|
||||
Partial Class LookupGridView
|
||||
Inherits System.ComponentModel.Component
|
||||
|
||||
<System.Diagnostics.DebuggerNonUserCode()> _
|
||||
<System.Diagnostics.DebuggerNonUserCode()>
|
||||
Public Sub New(ByVal container As System.ComponentModel.IContainer)
|
||||
MyClass.New()
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
End Sub
|
||||
|
||||
<System.Diagnostics.DebuggerNonUserCode()> _
|
||||
<System.Diagnostics.DebuggerNonUserCode()>
|
||||
Public Sub New()
|
||||
MyBase.New()
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
End Sub
|
||||
|
||||
'Die Komponente überschreibt den Löschvorgang zum Bereinigen der Komponentenliste.
|
||||
<System.Diagnostics.DebuggerNonUserCode()> _
|
||||
<System.Diagnostics.DebuggerNonUserCode()>
|
||||
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
|
||||
Try
|
||||
If disposing AndAlso components IsNot Nothing Then
|
||||
@@ -39,7 +39,7 @@
|
||||
'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.
|
||||
<System.Diagnostics.DebuggerStepThrough()> _
|
||||
<System.Diagnostics.DebuggerStepThrough()>
|
||||
Private Sub InitializeComponent()
|
||||
components = New System.ComponentModel.Container()
|
||||
End Sub
|
||||
|
||||
@@ -52,4 +52,5 @@ Namespace LookupGrid
|
||||
End Function
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
End Namespace
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ Imports System.Runtime.InteropServices
|
||||
|
||||
<Assembly: AssemblyTitle("LookupGrid")>
|
||||
<Assembly: AssemblyDescription("")>
|
||||
<Assembly: AssemblyCompany("")>
|
||||
<Assembly: AssemblyCompany("Digital Data")>
|
||||
<Assembly: AssemblyProduct("LookupGrid")>
|
||||
<Assembly: AssemblyCopyright("Copyright © 2018")>
|
||||
<Assembly: AssemblyTrademark("")>
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
DevExpress.XtraEditors.ButtonEdit, DevExpress.XtraEditors.v18.1, Version=18.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
|
||||
DevExpress.XtraEditors.TextEdit, DevExpress.XtraEditors.v18.1, Version=18.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
|
||||
DevExpress.XtraGrid.GridControl, DevExpress.XtraGrid.v18.1, Version=18.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
|
||||
|
||||
@@ -90,30 +90,35 @@ Public Class frmLookupGrid
|
||||
view.FindFilterText = String.Empty
|
||||
|
||||
If MultiSelect Then
|
||||
Dim values As New List(Of Object)
|
||||
Dim oValues 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)
|
||||
For oIndex = 0 To viewLookup.DataRowCount - 1
|
||||
Dim oRow As DataRow = view.GetDataRow(oIndex)
|
||||
Dim oSelected As Boolean = oRow.Item(0)
|
||||
Dim oValue As Object = oRow.Item(1)
|
||||
|
||||
If selected Then
|
||||
values.Add(value)
|
||||
If oSelected Then
|
||||
oValues.Add(oValue)
|
||||
End If
|
||||
Next
|
||||
|
||||
' Doppelte Werte entfernen, wenn konfiguriert
|
||||
If PreventDuplicates Then
|
||||
values = values.Distinct().ToList()
|
||||
oValues = oValues.Distinct().ToList()
|
||||
End If
|
||||
|
||||
SelectedValues = values
|
||||
SelectedValues = oValues
|
||||
Else
|
||||
Dim rowHandle As Integer = view.GetSelectedRows().ToList().First()
|
||||
Dim row As DataRow = view.GetDataRow(rowHandle)
|
||||
Dim value = row.Item(0)
|
||||
Dim oRowHandle As Integer = view.GetSelectedRows().ToList().FirstOrDefault()
|
||||
Dim oRow As DataRow = view.GetDataRow(oRowHandle)
|
||||
Dim oValues As New List(Of Object)
|
||||
|
||||
SelectedValues = New List(Of Object) From {value}
|
||||
If oRow IsNot Nothing Then
|
||||
Dim oValue = oRow.Item(0)
|
||||
oValues.Add(oValue)
|
||||
End If
|
||||
|
||||
SelectedValues = oValues
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
Reference in New Issue
Block a user