Solved

Positioning elements in a control array.

Posted on 1998-06-16
4
140 Views
Last Modified: 2010-05-03
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

0
Comment
Question by:peterwest
  • 2
  • 2
4 Comments
 
LVL 2

Expert Comment

by:swilt
ID: 1463361
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
0
 
LVL 2

Author Comment

by:peterwest
ID: 1463362
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

0
 
LVL 2

Accepted Solution

by:
swilt earned 50 total points
ID: 1463363
Glad I could be of some help

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
0
 
LVL 2

Author Comment

by:peterwest
ID: 1463364
Cheers
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question