Link to home
Start Free TrialLog in
Avatar of peterwest
peterwest

asked on

Positioning elements in a control array.

Hi there,

I'm writing a routine that dynamically adds check boxes onto a form based on the contents of a database; the routine that loads the controls and positions them down the form works fine but i'm having the following problem.

As I create the controls and move them down the form I need to resize the Frame3D control that holds them, move a group of buttons below the frame and also resize the form.  I've tried writing code to do this but i'm having a few problems with the co-ordinate system in VB.

I'm placed the buttons that need moving into a picturebox that now acts as the container, thus I only have to move the picturebox and not all the individual buttons.  However, if I resize the frame, form and move the picturebox by the appropriate amount i'm left with either big gaps or the newly created items are chopped off - why is this?  Is there some kind of weird scaling issue that i'm not aware of??

Thanks

Pete

Avatar of swilt
swilt

It works for me !
What does your code look like ?

Private Sub Command1_Click()
    Const cGap = 240
    Dim bNew As Integer
   
    bNew = Option1.Count
    Load Option1(bNew)
    Option1(bNew).Caption = "Option" & bNew
    Option1(bNew).Top = Option1(bNew - 1).Top + cGap
    Option1(bNew).Visible = True
    Frame1.Height = Frame1.Height + cGap
    Picture1.Top = Picture1.Top + cGap
    Me.Height = Me.Height + cGap
End Sub
Avatar of peterwest

ASKER

Hi,

I've had a look at my code again and realised what the problem was - I only want to resize the form and move the button container object when a certain number of items have been added.  This is because up until a point the container holding the control array is not as tall as other container objects on the same row; i've tweaked the code and it works fine now.

You're comment pointed me in the right direction so if you want to post an answer I'll happily pass the points over to you.

Regards

Pete

ASKER CERTIFIED SOLUTION
Avatar of swilt
swilt

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Cheers