?
Solved

Move Controls on User Control when it, and its containing form are resized to maintain correct positioning on the form.

Posted on 2003-03-14
4
Medium Priority
?
149 Views
Last Modified: 2010-05-01
Basically I have a form and a user control.  I bought ResizeKit hoping it would take care of all the resizing I need. . .but.

On the user control I have a textbox, three command buttons and a listview.  I have the usercontrol resizing proportionatly to the form.  Resizekit seems to only resize everything into crayon draw blurb where I just want the list view to grow proportionatly to the size of the screen, and the other controls(two command buttons below the list box) to move to where they should be relative to where they started.

I have been search for a while for the code I would need to do this with no luck.  I don't need to resize anything but the listview, I just want to move everything else.  

How do I do this?
0
Comment
Question by:adamkushner
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
JohnMcCann earned 200 total points
ID: 8136309
In the Form_Resize event.

Add some code that will go something like

Private Sub Form_Resize()
   Me.ScaleMode = vbPixels
   
   ListView1.Move 0, 0, ScaleWidth, ScaleHeight - (Command1.Height * 2)
   
   With Command1
      .Move .Left, ScaleHeight - (Command1.Height * 1.5)
   End With
   
   With Command2
      .Move .Left, ScaleHeight - (Command1.Height * 1.5)
   End With
   
   With Command3
      .Move .Left, ScaleHeight - (Command1.Height * 1.5)
   End With
   
   With Text1
      .Move .Left, ScaleHeight - (Command1.Height * 1.5)
   End With
End Sub

The only problem is you will need to resize your command buttons and edit control.

I'll be happy to help you with that.
0
 

Author Comment

by:adamkushner
ID: 8136811
Me.ScaleMode = vbPixels

What exactly does this do?  I'm using a usercontrol so .ScaleMode is not availible.
0
 
LVL 5

Expert Comment

by:JohnMcCann
ID: 8137034
UserControl.ScaleMode = vbPixels

The only reason I did  that is force of habit as the windows API uses Pixels as its logical measurement.  I hope I habve not confused you as you did not need that line in this example.
0
 

Author Comment

by:adamkushner
ID: 8137121
No problem.
Thanks for the code, it was just the example I needed for my app.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
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…
Suggested Courses
Course of the Month10 days, 7 hours left to enroll

765 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