Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 152
  • Last Modified:

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

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
adamkushner
Asked:
adamkushner
  • 2
  • 2
1 Solution
 
JohnMcCannCommented:
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
 
adamkushnerAuthor Commented:
Me.ScaleMode = vbPixels

What exactly does this do?  I'm using a usercontrol so .ScaleMode is not availible.
0
 
JohnMcCannCommented:
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
 
adamkushnerAuthor Commented:
No problem.
Thanks for the code, it was just the example I needed for my app.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now