2021-10-15 14:56:46 +02:00

60 lines
1.7 KiB
VB.net

Imports DevExpress.XtraGrid
Imports DevExpress.XtraGrid.Views.Grid
Imports DigitalData.Modules.Logging
Imports ImporterShared
Public Class GridLoader
Inherits BaseClass
Public Sub New(pLogConfig As LogConfig)
MyBase.New(pLogConfig, pLogConfig.GetLogger())
End Sub
Public Function GetGridFromElement(pTable As Schemas.Schema.Table) As GridControl
Dim oGrid As New GridControl With {
.Dock = DockStyle.Fill,
.Name = pTable.Name
}
oGrid.ForceInitialize()
oGrid.MainView.PopulateColumns()
Dim oView As GridView = oGrid.DefaultView
For Each oCol In pTable.Columns
Dim oColumn = New Columns.GridColumn With {
.Name = oCol.Name,
.Caption = oCol.Name,
.FieldName = oCol.Name,
.UnboundType = GetColumnType(oCol),
.VisibleIndex = 0
}
oView.Columns.Add(oColumn)
Next
Return oGrid
End Function
Private Function GetColumnType(pColumn As Schemas.Schema.Column)
Select Case pColumn.DataType
Case Schemas.Schema.ColumnType.Boolean
Return DevExpress.Data.UnboundColumnType.Boolean
Case Schemas.Schema.ColumnType.Date
Return DevExpress.Data.UnboundColumnType.DateTime
Case Schemas.Schema.ColumnType.Integer
Return DevExpress.Data.UnboundColumnType.Integer
Case Schemas.Schema.ColumnType.Decimal
Return DevExpress.Data.UnboundColumnType.Decimal
Case Else
Return DevExpress.Data.UnboundColumnType.String
End Select
End Function
End Class