I have a basic form "template" that I load with controls from an XML file.
The structure of the "template" is
TabControl
1 TabPage
2 GroupBox Columns on TabPage.
The dynamic Controls that are loaded are
1 (or more) GroupBox containers
1 (or more) GroupBox container with (6 buttons, 4 texboxes, 2 labels)
I create each control and "Add" to the Container control
Each control as the properties
oControl.Visible = True
oControl.BringToFront()
set.
The code loops through each group and dependent boxes.
If the maximums are exceeded then a new Tab Page is created.
The code runs through with no errors, but when the form is displayed no created controls are visible, nor is the instruction to select the first TabPage obeyed.
Pretty much everything that is generated is ignored.
These are some code snippets:
I've looped through all the controls in the form and ALL the created controls are there, nested inside the correct controls, but are they visible, are they heck!
I have no problem when using the Designer to add controls, but this is the first time I've been adventurous and tried to dynamically create a form...
A step too far perhaps, but it's the only way for this application...
The attached image shows the hierarchy of the nested containers.
The structure of the "template" is
TabControl
1 TabPage
2 GroupBox Columns on TabPage.
The dynamic Controls that are loaded are
1 (or more) GroupBox containers
1 (or more) GroupBox container with (6 buttons, 4 texboxes, 2 labels)
I create each control and "Add" to the Container control
Each control as the properties
oControl.Visible = True
oControl.BringToFront()
set.
The code loops through each group and dependent boxes.
If the maximums are exceeded then a new Tab Page is created.
The code runs through with no errors, but when the form is displayed no created controls are visible, nor is the instruction to select the first TabPage obeyed.
Pretty much everything that is generated is ignored.
These are some code snippets:
VB.NET:
Public Function AddGroupBox(ByVal vTitle As String,
ByVal vType As GroupType,
Optional ByVal vInstance As Integer = 0) As System.Windows.Forms.GroupBox
Dim iTop As Integer
Dim iLeft As Integer
Try
' Create control
Dim oGroupBox As New System.Windows.Forms.GroupBox
oGroupBox.Text = vTitle
Select Case vType
Case GroupType.gOuterBox
iLeft = (player.Columns * gWidth) + gOffset
oGroupBox.Name = Join({"GroupBox", CStr(player.Tab), CStr(player.GroupOffset)}, "_")
oGroupBox.Location = New System.Drawing.Point(iLeft, 9)
oGroupBox.Size = New System.Drawing.Size(gWidth, gMinHeight)
oGroupBox.Font = New Font("Arial", 11, FontStyle.Bold)
oGroupBox.ForeColor = oBlue
oGroupBox.AutoSize = True
Case GroupType.gInnerBox
iTop = (vInstance * mHeight) + mOffset
oGroupBox.Name = Join({"MP3", CStr(player.Tab), CStr(player.GroupOffset), CStr(player.MP3Offset)}, "_")
oGroupBox.Location = New System.Drawing.Point(mLeft, iTop)
oGroupBox.Size = New System.Drawing.Size(mWidth, mHeight)
oGroupBox.Font = New Font("Arial", 9, FontStyle.Bold)
oGroupBox.ForeColor = oBlack
oGroupBox.AutoSize = False
Case GroupType.gColumn
oGroupBox.Text = ""
Select Case vInstance
Case 1
iLeft = 0
Case 2
iLeft = 395
End Select
oGroupBox.Name = Join({"column", CStr(vInstance)}, "_")
oGroupBox.Location = New System.Drawing.Point(iLeft, 2)
oGroupBox.Size = New System.Drawing.Size(395, 629)
oGroupBox.AutoSize = False
End Select
oGroupBox.Visible = True
oGroupBox.BringToFront()
Return oGroupBox
Catch ex As Exception
End Try
Return Nothing
End Function
VB.NET:
cControl = AddGroupBox(vTitle:=sTitle,vInstance:=iOffset,vType:=GroupType.gInnerBox)
cGroup.Controls.Add(cControl)
I've looped through all the controls in the form and ALL the created controls are there, nested inside the correct controls, but are they visible, are they heck!
I have no problem when using the Designer to add controls, but this is the first time I've been adventurous and tried to dynamically create a form...
A step too far perhaps, but it's the only way for this application...
The attached image shows the hierarchy of the nested containers.
Attachments
Last edited: