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.Web.ASPxHtmlEditor
Imports DevExpress.ExpressApp.HtmlPropertyEditor.Web
Imports System.Web.UI.WebControls
Imports System.Web.UI
Imports DevExpress.ExpressApp.Editors

Public Class HTMLEditorVC
    Inherits DevExpress.ExpressApp.ViewController(Of DetailView)
    Private htmlEditors As ArrayList
    Public Sub New()
        MyBase.New()
        htmlEditors = New ArrayList
        htmlEditors.Clear()
        'This call is required by the Component Designer.
        InitializeComponent()
        RegisterActions(components)

    End Sub
    Protected Overrides Sub OnViewControlsCreated()
        MyBase.OnViewControlsCreated()
        Dim editor As ASPxHtmlPropertyEditor
        Dim htmlEditor As ASPxHtmlEditor
        If View.ViewEditMode = Editors.ViewEditMode.Edit Then
            For Each editor In View.GetItems(Of ASPxHtmlPropertyEditor)()
                If TryCast(editor.Control, Table) IsNot Nothing Then
                    htmlEditor = TryCast(editor.Control, Table).Rows(0).Cells(1).Controls(0)
                    If htmlEditor IsNot Nothing Then
                        htmlEditors.Add(htmlEditor)
                    End If
                End If
            Next
            AddHandler TryCast(View.Control, Control).PreRender, AddressOf ChangeHtmlEditorWidthController_PreRender
        End If
    End Sub
    Sub ChangeHtmlEditorWidthController_PreRender(sender As Object, e As EventArgs)
        Dim htmlEditor As ASPxHtmlEditor

        For Each htmlEditor In htmlEditors
            htmlEditor.Width = Unit.Percentage(100)
        Next
        htmlEditors.Clear()
    End Sub
End Class
