Move Position Tab Control

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to move or reposition a tab control on a form in the runtime
environment. When I try either the MOVE commane or position commands like
LEFT etc.... it just make the tab control bigger, but it does not move it or
reposistion it on the form. what am I doing wrong?
--Tony
 
Tony,
If a control was located at Left = 500 twips and had a width of 100 twips
then...
YourControl.Left = 300
YourControl.Width = 100
will move the control 200 twips to the left... and maintain the original
width.
hth
Al Camp
 
Tony said:
I'm trying to move or reposition a tab control on a form in the runtime
environment. When I try either the MOVE commane or position commands like
LEFT etc.... it just make the tab control bigger, but it does not move it or
reposistion it on the form. what am I doing wrong?


The problem is that when you move a container control (tab
control, option group frame, ...) those methods only try to
move the container, they do not attempt to move the controls
within the container.

Unfortunately there is sort of catch 22 kind of thing going
on if you code up a routine to move everthing. Moving a
control may run out of space as the container is enlarged to
continue to contain it, but moving the container first may
not work because a control may not be within the new
position. This whole situation can be such a pain as to
make you come up a new UI plan that doesn't require this
kind of movement.
 
Al,

Nice suggestion, but I tried that and it doesn't work. It still just
enlarges the tab control.
 
Marshall said:
The problem is that when you move a container control (tab
control, option group frame, ...) those methods only try to
move the container, they do not attempt to move the controls
within the container.

Unfortunately there is sort of catch 22 kind of thing going
on if you code up a routine to move everthing. Moving a
control may run out of space as the container is enlarged to
continue to contain it, but moving the container first may
not work because a control may not be within the new
position. This whole situation can be such a pain as to
make you come up a new UI plan that doesn't require this
kind of movement.

Agreed. This definitely falls into the category of "Doctor it hurts when I do
this".
 
How about this?
It doesn't seem too painful:

(again, assuming a width of 100)
MyTabCtl.Left=MyTabCtl.Left-200
Dim ctl as Control
For each ctl in MyTabCtl.Controls
ctl.left=ctl.left-200
next
MyTabCtl.width=100

This should work as long as the controls on your tab all have a .Left
property.
If some of them are lines or rectangles, you'll have to code for that, too.
 
Sorry about that... as you can tell, I've never moved a tab control before.
I was sure it was just the width adjustment you were missing.
Al Camp
 
Marsh,

Thanks for the tip. For a simple tab control, your solution works.
Unfortunately, mine is fairly complex with 10 tabs each with tons of
controls, lines, rectangles etc... Seems like too much trouble to code for
all of them... plus, when I do I can actually see the tab control move across
the screen (and I have a 3 GHz machine!) so on a slower machine.... could be
a problem.
--Tony

MacDermott said:
How about this?
It doesn't seem too painful:

(again, assuming a width of 100)
MyTabCtl.Left=MyTabCtl.Left-200
Dim ctl as Control
For each ctl in MyTabCtl.Controls
ctl.left=ctl.left-200
next
MyTabCtl.width=100

This should work as long as the controls on your tab all have a .Left
property.
If some of them are lines or rectangles, you'll have to code for that, too.
 
Actually, you can cover all lines and rectangles in a single set of code,
since they all have x1, x2, y1, y2 properties, and all you'd have to do is
subtract the appropriate amount from the appropriate properties.
If a control throws an error when you reference its .Left property, use the
other ones.

You can set
Me.Painting=False
before beginning the loop, and
Me.Painting=True
afterwards.
If it's going to take some time, you might want to use DoCmd.Hourglass as
well.

HTH
(BTW, I'm not Marshall - wish I did know all he does! - but I assume
your comment was directed to my post.)

Tony said:
Marsh,

Thanks for the tip. For a simple tab control, your solution works.
Unfortunately, mine is fairly complex with 10 tabs each with tons of
controls, lines, rectangles etc... Seems like too much trouble to code for
all of them... plus, when I do I can actually see the tab control move across
the screen (and I have a 3 GHz machine!) so on a slower machine.... could be
a problem.
--Tony
 
Back
Top