Solved

Positioning elements in a control array.

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

757 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

21 Experts available now in Live!

Get 1:1 Help Now