Overview: Creating a small app to assist with reviewing log files for SCCM.
I just started working on a small app to analyze log files. The main form has an empty TabControl named "tcMain". It also has a button (For testing purposes) which will create a new "LogAssembly" class. This class contains the UI elements for a TabPage and other nested controls.
Inside of the LogAssembly class is a RichTextBox. It is anchored in a fashion where the text box will grow with the form size.
Problem: The first "LogAssembly" created works as intended. tcMain is populated and everything looks well. The richtextbox resizes as expected.
Any subsequent LogAssembly have issues. The rich textbox is huge and seems fill beyond the controls in which it is nested.
I suspect the issue has to do with the order inwhich i am creating / manipulating the controls. However, I do not have firm grasp of control management at runtime. I hope someone can point out what I am doing wrong here.
Here is the pertinent code:
Form1: (Press btnOptions to create new "LogAssembly" on tcMain)
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Text = "SCCM Log Analyzer (v" & APP_VERSION & ")"
End Sub
Private Sub btnOptions_Click(sender As Object, e As EventArgs) Handles btnOptions.Click
Dim TestA As New LogAssembly(tcMain, "Example_")
End Sub
End Class
LogAssembly Class:
Public Class LogAssembly
Public UI_ParentTab As TabPage = New TabPage
'Main UI Elements
Public UI_GroupBoxA As GroupBox = New GroupBox
Public UI_ChildTabControl As TabControl = New TabControl
Public UI_PageEvents As TabPage = New TabPage
Public UI_PageText As TabPage = New TabPage
Public UI_PageItem As TabPage = New TabPage
'Event View Elements
Public UI_EventsText As RichTextBox = New RichTextBox
Public UI_EventsResearch As Button = New Button
Public Sub New(ByRef parent As TabControl, ByVal data As String)
UI_ParentTab.Text = data
parent.TabPages.Add(UI_ParentTab)
'Group Box UI
UI_GroupBoxA.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) Or System.Windows.Forms.AnchorStyles.Left) Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
UI_ParentTab.Controls.Add(UI_GroupBoxA)
UI_GroupBoxA.Location = New System.Drawing.Point(5, 5)
UI_GroupBoxA.Size = New Point(912, 405)
UI_GroupBoxA.Text = "Selected Log"
'Tab Control UI
UI_GroupBoxA.Controls.Add(UI_ChildTabControl)
UI_ChildTabControl.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) Or System.Windows.Forms.AnchorStyles.Left) Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
UI_ChildTabControl.Location = New System.Drawing.Point(5, 15)
UI_ChildTabControl.Size = New Point(900, 385)
'Tab Page Events
UI_ChildTabControl.TabPages.Add(UI_PageEvents)
UI_PageEvents.Text = "Event View"
UI_PageEvents.Controls.Add(UI_EventsText)
UI_PageEvents.Controls.Add(UI_EventsResearch)
'_TextBox
UI_EventsText.Text = data
UI_EventsText.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) Or System.Windows.Forms.AnchorStyles.Left) Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
UI_EventsText.Location = New System.Drawing.Point(5, 30)
UI_EventsText.Size = New Point(490, 140)
'_Button
UI_EventsResearch.Location = New Point(5, 5)
UI_EventsResearch.Text = "Things"
'Tab Page Text
UI_ChildTabControl.TabPages.Add(UI_PageText)
UI_PageText.Text = "Text View"
'Tab Page Item
UI_ChildTabControl.TabPages.Add(UI_PageItem)
UI_PageItem.Text = "Item View"
End Sub
End Class