From 764adc712360da09209232e1aebbcee5810477b6 Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Mon, 19 Apr 2021 16:30:15 +0200 Subject: [PATCH] Common: Add GridBuilder --- GUIs.Common/Common.vbproj | 1 + GUIs.Common/GridBuilder.vb | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 GUIs.Common/GridBuilder.vb diff --git a/GUIs.Common/Common.vbproj b/GUIs.Common/Common.vbproj index 230330ad..33c6ff7d 100644 --- a/GUIs.Common/Common.vbproj +++ b/GUIs.Common/Common.vbproj @@ -114,6 +114,7 @@ Form + diff --git a/GUIs.Common/GridBuilder.vb b/GUIs.Common/GridBuilder.vb new file mode 100644 index 00000000..87da002f --- /dev/null +++ b/GUIs.Common/GridBuilder.vb @@ -0,0 +1,32 @@ +Imports DevExpress.XtraGrid +Imports DevExpress.XtraGrid.Views.Grid + +Public Class GridBuilder + Public ReadOnly Property Views As New List(Of GridView) + + Public Sub New(GridView As GridView) + Views.Add(GridView) + End Sub + + Public Sub New(GridViews As List(Of GridView)) + Views.AddRange(GridViews) + End Sub + + Public Function WithDefaults() As GridBuilder + For Each oView In Views + oView.OptionsView.EnableAppearanceEvenRow = True + oView.OptionsView.ShowAutoFilterRow = True + Next + + Return Me + End Function + + Public Function WithReadOnlyOptions() As GridBuilder + For Each oView In Views + oView.OptionsBehavior.Editable = False + oView.OptionsBehavior.ReadOnly = True + Next + + Return Me + End Function +End Class