Replace old stinky Table with fancy GridControl

This commit is contained in:
Jonathan Jenne
2019-04-11 15:48:12 +02:00
parent 93716bcc96
commit 8dadf1ff30
6 changed files with 259 additions and 159 deletions

View File

@@ -1,4 +1,7 @@
Imports DD_LIB_Standards
Imports DevExpress.Utils
Imports DevExpress.XtraGrid
Imports DevExpress.XtraGrid.Views.Grid
Imports DigitalData.Controls.LookupGrid
Public Class ClassControlCreator
@@ -25,6 +28,7 @@ Public Class ClassControlCreator
Public Const PREFIX_TABLE = "TB"
Public Const PREFIX_LINE = "LINE"
''' <summary>
''' Standard Eigenschaften für alle Controls
''' </summary>
@@ -168,30 +172,22 @@ Public Class ClassControlCreator
Return control
End Function
Public Shared Function CreateNewTable(location As Point) As DataGridView
Dim control As New DataGridView With {
Public Shared Function CreateNewTable(location As Point) As GridControl
Dim oControl As New GridControl With {
.Name = $"{PREFIX_TABLE}_{clsTools.ShortGuid}",
.Size = New Size(DEFAULT_WIDTH, DEFAULT_HEIGHT_TABLE),
.Cursor = Cursors.Hand,
.Location = location,
.AllowUserToAddRows = False,
.AllowUserToDeleteRows = False,
.AllowUserToResizeColumns = False,
.AllowUserToResizeRows = False
.Location = location
}
Dim oView As GridView = oControl.DefaultView
oView.OptionsView.ShowGroupPanel = False
control.Columns.Add(New DataGridViewTextBoxColumn With {
.HeaderText = "Column1",
.Name = "column1"
})
Dim oDatatable As New DataTable()
oDatatable.Columns.Add("column1", GetType(String))
oDatatable.Columns.Add("column2", GetType(String))
oControl.DataSource = oDatatable
control.Columns.Add(New DataGridViewTextBoxColumn With {
.HeaderText = "Column2",
.Name = "column2"
})
Return control
Return oControl
End Function
Public Shared Function CreateNewLine(location As Point) As LineLabel
@@ -319,31 +315,46 @@ Public Class ClassControlCreator
Return control
End Function
Public Shared Function CreateExistingTable(row As DataRow, columns As List(Of DD_DMSLiteDataSet.TBPM_CONTROL_TABLERow), designMode As Boolean) As DataGridView
Dim control As DataGridView = CreateBaseControl(New DataGridView(), row, designMode)
Public Shared Function CreateExistingTable(row As DataRow, columns As List(Of DD_DMSLiteDataSet.TBPM_CONTROL_TABLERow), designMode As Boolean) As GridControl
Dim oControl As GridControl = CreateBaseControl(New GridControl(), row, designMode)
Dim oDatatable As New DataTable
Dim oView As GridView
control.Size = New Size(row.Item("WIDTH"), row.Item("HEIGHT"))
control.AllowUserToAddRows = False
control.AllowUserToDeleteRows = False
control.AllowUserToResizeColumns = False
control.AllowUserToResizeRows = False
For Each column As DD_DMSLiteDataSet.TBPM_CONTROL_TABLERow In columns
Dim col As New DataGridViewTextBoxColumn() With {
.HeaderText = column.SPALTEN_HEADER,
.Name = column.SPALTENNAME,
.Width = column.SPALTENBREITE
}
control.Columns.Add(col)
Next
oControl.ForceInitialize()
oView = oControl.DefaultView
oView.OptionsView.ShowGroupPanel = False
If Not designMode Then
control.Enabled = Not row.Item("READ_ONLY")
control.TabStop = Not row.Item("READ_ONLY")
oView.OptionsBehavior.Editable = Not row.Item("READ_ONLY")
oView.OptionsBehavior.ReadOnly = row.Item("READ_ONLY")
If row.Item("VKT_ADD_ITEM") = True Then
oView.OptionsBehavior.AllowAddRows = DefaultBoolean.True
oView.OptionsView.NewItemRowPosition = NewItemRowPosition.Bottom
Else
oView.OptionsBehavior.AllowAddRows = DefaultBoolean.False
oView.OptionsView.NewItemRowPosition = NewItemRowPosition.None
End If
End If
Return control
oControl.Size = New Size(row.Item("WIDTH"), row.Item("HEIGHT"))
For Each oRow As DD_DMSLiteDataSet.TBPM_CONTROL_TABLERow In columns
Dim oColumn = New DataColumn() With {
.DataType = GetType(String),
.ColumnName = oRow.SPALTENNAME,
.Caption = oRow.SPALTEN_HEADER
}
oDatatable.Columns.Add(oColumn)
Next
oControl.DataSource = oDatatable
Return oControl
End Function
Public Shared Function CreateExistingLine(row As DataRow, designMode As Boolean) As LineLabel