Form Concepts CodeSample - Simulating IFRAMEs
From Visual WebGui Wiki
| This article will have a few sections added to it soon, based on the following article type skeleton: NewCodeSampleTemplate |
Contents |
Overview
This article is a part of Form Concepts series of articles.
The codesample shows how you use a single Panel and ToolBar for navigation and for each option selected, dynamically creating the corresponding UserControl and replacing the contents within the Panel.
This method for navigation is one of two similar ones where you use dynamically created UserControls instead of Forms. The other method can be found in UserControls on Tabs.
Background
This sample is based on the video tutorial presented in the Video references section in Form Concepts. Pay special attention to View3Control, as in that control contents are loaded dynamically and only when the control is requested by the toolbar buttons. For big applications with a lot of views, this means that users are unlikely to visit all the views in any one session, and only when that view is requestes, the data is loaded. This can save a lot of loading time and resources for those big applications.
The code for the UserControls is not included here, and you should view the video to see it.
VB.NET Code
Imports Gizmox.WebGui.Forms Public Class IFRAMESform Friend WithEvents ToolBar1 As Gizmox.WebGui.Forms.ToolBar Friend WithEvents Panel1 As Gizmox.WebGui.Forms.Panel Friend WithEvents ToolBarButton1 As Gizmox.WebGui.Forms.ToolBarButton Friend WithEvents ToolBarButton2 As Gizmox.WebGui.Forms.ToolBarButton Friend WithEvents ToolBarButton3 As Gizmox.WebGui.Forms.ToolBarButton Sub New() ' This call is required by the Windows Form Designer. InitializeComponent() ' Add any initialization after the InitializeComponent() call. Me.ToolBar1 = New Gizmox.WebGui.Forms.ToolBar Me.Panel1 = New Gizmox.WebGui.Forms.Panel Me.ToolBarButton1 = New Gizmox.WebGui.Forms.ToolBarButton Me.ToolBarButton2 = New Gizmox.WebGui.Forms.ToolBarButton Me.ToolBarButton3 = New Gizmox.WebGui.Forms.ToolBarButton ' 'ToolBar1 ' Me.ToolBar1.Anchor = Gizmox.WebGui.Forms.AnchorStyles.None Me.ToolBar1.Appearance = Gizmox.WebGui.Forms.ToolBarAppearance.Normal Me.ToolBar1.Buttons.AddRange(New Gizmox.WebGui.Forms.ToolBarButton() {Me.ToolBarButton1, Me.ToolBarButton2, Me.ToolBarButton3}) Me.ToolBar1.Dock = Gizmox.WebGui.Forms.DockStyle.Top Me.ToolBar1.DragHandle = True Me.ToolBar1.DropDownArrows = False Me.ToolBar1.ImageList = Nothing Me.ToolBar1.Location = New System.Drawing.Point(0, 0) Me.ToolBar1.MenuHandle = True Me.ToolBar1.Name = "ToolBar1" Me.ToolBar1.RightToLeft = False Me.ToolBar1.ShowToolTips = True Me.ToolBar1.TabIndex = 0 ' 'Panel1 ' Me.Panel1.Anchor = Gizmox.WebGui.Forms.AnchorStyles.None Me.Panel1.BorderStyle = Gizmox.WebGui.Forms.BorderStyle.Clear Me.Panel1.Dock = Gizmox.WebGui.Forms.DockStyle.Fill Me.Panel1.Location = New System.Drawing.Point(0, 28) Me.Panel1.Name = "Panel1" Me.Panel1.Size = New System.Drawing.Size(690, 478) Me.Panel1.TabIndex = 1 ' 'ToolBarButton1 ' Me.ToolBarButton1.CustomStyle = "" Me.ToolBarButton1.Name = "ToolBarButton1" Me.ToolBarButton1.Pushed = True Me.ToolBarButton1.Size = 24 Me.ToolBarButton1.Tag = "View1" Me.ToolBarButton1.Text = "View1" Me.ToolBarButton1.ToolTipText = "" ' 'ToolBarButton2 ' Me.ToolBarButton2.CustomStyle = "" Me.ToolBarButton2.Name = "ToolBarButton2" Me.ToolBarButton2.Pushed = True Me.ToolBarButton2.Size = 24 Me.ToolBarButton2.Tag = "View2" Me.ToolBarButton2.Text = "View2" Me.ToolBarButton2.ToolTipText = "" ' 'ToolBarButton3 ' Me.ToolBarButton3.CustomStyle = "" Me.ToolBarButton3.Name = "ToolBarButton3" Me.ToolBarButton3.Pushed = True Me.ToolBarButton3.Size = 24 Me.ToolBarButton3.Tag = "View3" Me.ToolBarButton3.Text = "View3" Me.ToolBarButton3.ToolTipText = "" ' 'IFRAMESform ' Me.Controls.Add(Me.Panel1) Me.Controls.Add(Me.ToolBar1) Me.Size = New System.Drawing.Size(690, 506) Me.Text = "IFRAMESform" End Sub Private Sub ToolBar1_Click(ByVal objSource As System.Object, ByVal objArgs As Gizmox.WebGui.Forms.ToolBarItemEventArgs) Handles ToolBar1.Click Dim objControl As Control = Nothing If objArgs.ToolBarButton.Tag = "View1" Then objControl = New View1Control ElseIf objArgs.ToolBarButton.Tag = "View2" Then objControl = New View2Control ElseIf objArgs.ToolBarButton.Tag = "View3" Then objControl = New View3control End If If objControl IsNot Nothing Then Panel1.Controls.Clear() Panel1.Controls.Add(objControl) End If End Sub End Class
C# Code
| The conversion of this code to C# has not been completed yet. Please feel free to contribute and add contents to the Wiki |
