I am writing a program that will take input from the user in the form of a tree-view and create a form and a database based on the tree-view. I have everything working except the group-box control for the boolean expression. I will give a sample code of the text boxes that do work and then I will give the code that is not working.
For Each babyNode In childNode.Nodes
If babyNode.Text.ToString = "Small Text ( Less than 255 Characters )" Then
Dim TextField As New System.Windows.Forms.TextBox
Dim labelField As New System.Windows.Forms.Label
'Create and position the label field
With labelField
.Name = fieldName & "label:"
.Text = fieldName
iSizW = .Size.Width
iSizH = .Size.Height
.Left = iLocX
.Top = iLocY
tabPage.Controls.Add(labelField)
End With
'Create and position the text field
With TextField
.Name = fieldName
.Multiline = False
.WordWrap = False
.MaxLength = 255
.Text = babyNode.NextNode.Text.ToString
.Visible = True
iSizW = .Size.Width
iLocX = iLocX + iSizW + 5
.Left = iLocX
.Top = iLocY
tabPage.Controls.Add(TextField)
End With
'Increment the Location for the next label field
iLocX = iLocX + iSizW + 10
'Check to see if the control is going to run of the form, if it
'is then go down to the next row
If (iLocX + iSizW > Me.Size.Width - 20) Then
iLocX = 5
iLocY = iLocY + iSizH + 5
End If
Exit For
That works perfectly. This is the group box control that is not working:
ElseIf babyNode.Text.ToString = "Boolean (True or False)" Then
Dim tempX As Integer
tabPage.Controls.Add(groupBoxItem)
With groupBoxItem
.Name = fieldName
.Text = fieldName
.Width = 217
.Height = 40
iSizW = .Width
iSizH = .Height
iLocX = iLocX + iSizW + 5
.Left = iLocX
.Top = iLocY
.Controls.Add(booleanTrueField)
With booleanTrueField
.Text = "True"
.Top = 14
iSizW = .Size.Width
tempX = .Location.X
.Left = tempX + 5
If babyNode.NextNode.Text.ToString = "True" Then
.Checked = True
End If
End With
.Controls.Add(booleanFalseField)
With booleanFalseField
.Text = "False"
.Top = 14
.Left = tempX + iSizW + 5
tempX = .Location.X
iSizW = .Size.Width
If babyNode.NextNode.Text.ToString = "False" Then
.Checked = True
End If
End With
MsgBox("Adding Field: " & .Name.ToString & vbCr & "X: " & .Location.X & vbCr & "Y: " & .Location.Y)
End With
'Increment the Location for the next control
iLocX = iLocX + iSizW + 10
If (iLocX + iSizW > Me.Size.Width - 20) Then
iLocX = 5
iLocY = iLocY + iSizH + 5
End If
Exit For
Currently I am using Visual Studio 2005, VB 6 I think. If there are any questions, I would be happy to answer them - thanks in advance for any help I do receive.
P.S. in tests it seems to position them semi-correctly (at least not in the same spot) as indicated by messages I receive by the program - but when the form loads they are either one on top of another, or whichever is not the most recent addition is gone.