Solved

Positioning elements in a control array.

Posted on 1998-06-16
4
137 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

932 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now