| | |
Positioning a Group Box at Runtime - Help
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Jun 2007
Posts: 49
Reputation:
Solved Threads: 2
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.
That works perfectly. This is the group box control that is not working:
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.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
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:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
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.
Last edited by Mr.Wobbles; Apr 11th, 2008 at 1:32 pm.
Mr.Wobbles~
•
•
Join Date: Jun 2007
Posts: 49
Reputation:
Solved Threads: 2
Goodness, This was a simple fix, something that occurs when I stare at code to long - I miss the obvious. I was only declaring the group box at the beginning and therefore using the same one every time I ran the code. So I moved the group box intialization to after the ElseIf and everything works great. --
Mr.Wobbles~
![]() |
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Help, Assertion problem!!! :(
- Next Thread: Running a fortan program in VB-6
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
* 6 429 2007 access activex add age append application basic beginner birth bmp calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine table tags textbox time timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





