Imports System
Imports System.ComponentModel
Imports System.Collections.Generic
Imports System.Diagnostics
Imports System.Text

Imports DevExpress.ExpressApp
Imports DevExpress.ExpressApp.Actions
Imports DevExpress.Persistent.Base

Imports DevExpress.XtraGrid.Columns
Imports DevExpress.XtraGrid.Views.Grid
Imports DevExpress.XtraEditors.Controls
Imports DevExpress.XtraEditors.Repository
Imports DevExpress.ExpressApp.Win.Editors
Imports DevExpress.Data
Imports DevExpress.ExpressApp.Editors
Imports DevExpress.ExpressApp.Win.SystemModule
Imports DevExpress.XtraGrid.Views.BandedGrid
Imports DevExpress.XtraGrid

Public Class OrderVC
    Inherits DevExpress.ExpressApp.ViewController(Of ListView)
    Private _GridListEditor As GridListEditor
    Public Sub New()
        MyBase.New()
        'This call is required by the Component Designer.
        InitializeComponent()
        RegisterActions(components)
    End Sub
    Protected Overrides Sub OnViewControlsCreated()
        Dim _GridControl As GridControl
        Dim _BandedGridView As BandedGridView = Nothing
        Dim _GridView As GridView
        MyBase.OnViewControlsCreated()
        If View.Id = "OrderInHeader_OrderInRows_ListView" Or _
           View.Id = "OrderInHeaderFromOfferOutRowsHeader_OrderInHeaderFromOfferOutRowsRows_ListView" Then
            _GridListEditor = TryCast(View.Editor, GridListEditor)
            If _GridListEditor IsNot Nothing Then
                InitGridView()
                InitQTT_ProcessColumn()
                _GridView = _GridListEditor.GridView
                _GridControl = _GridView.GridControl

            End If
        End If
        
    End Sub
    Sub InitGridView()
        For i As Integer = 0 To _GridListEditor.Columns.Count - 1
            If _GridListEditor.GridView.Columns(i).FieldName Like "QTT_Process" Then
            Else
                _GridListEditor.GridView.Columns(i).OptionsColumn.ReadOnly = True
                _GridListEditor.GridView.Columns(i).OptionsColumn.AllowEdit = False
                _GridListEditor.GridView.Columns(i).OptionsColumn.TabStop = False
            End If
        Next i
    End Sub
    Sub InitQTT_ProcessColumn()
        For i As Integer = 0 To _GridListEditor.Columns.Count - 1
            Dim _ColumnWrapper As ColumnWrapper = _GridListEditor.Columns(i)
            If _ColumnWrapper.PropertyName = "QTT_Process" Then
                Dim QTT_ProcessColumn As GridColumn = _GridListEditor.GridView.Columns("QTT_Process")
                QTT_ProcessColumn.OptionsColumn.AllowEdit = True
                QTT_ProcessColumn.OptionsColumn.AllowFocus = True
                QTT_ProcessColumn.OptionsColumn.ReadOnly = False
                QTT_ProcessColumn.UnboundType = UnboundColumnType.Decimal
                Exit For
            End If
        Next
    End Sub

    Private Sub _row_Products_Editor_ControlValueChanged(sender As Object, e As EventArgs)
        Throw New NotImplementedException
    End Sub

End Class

Public Class Order
    Inherits ViewController
    Protected Overrides Sub OnActivated()
        MyBase.OnActivated()
        If View.Id Like "Order*Header_DetailView" Then
            Frame.GetController(Of WinModificationsController).ModificationsHandlingMode = SystemModule.ModificationsHandlingMode.Confirmation
        End If
        If View.Id Like "Order*Header_OrderInRows_ListView" Then
            Frame.GetController(Of DevExpress.ExpressApp.Win.SystemModule.OpenObjectController)().Active.SetItemValue("", False)
        End If
    End Sub
End Class