How to programmatically align the control's position (Left,Top)

accesser2003

Registered User.
Local time
Today, 07:32
Joined
Jun 2, 2007
Messages
124
I want to progammatically align the report controls position.
I have a control with left=2.7 in the Design view property.
I want to set programmatically set this value to 3.0 or other value accoring to a parameters. The problem is that when I set this property at the event Report-Open, the control appears always in another position regardless of the left value, i.e appears always at the new constant position.

What is the problem you think?
 
A,

The measurements are in "twips".

A twip is something like 1/1440 of an inch.

Experiment --> .Left = 1440 should move it one inch.

Wayne
 
Thanks for support,
 
A,

Gload to help.

btw, why are you moving them? Are you resizing fields due to data length?

Wayne
 
I had occasion to do something like this once:

I had eight buttons, but never more than five would be active at any one time due to the nature of the functions on this rather complicated little form. So what I did is I found the first button and aligned it so its top was 1 twip plus the top plus the height of a line that I drew as a border for all control buttons. The left of this button aligned to the left of the border line.

Then the next active button I moved to the same top and to a left equal to 1 plus the left plus the width of the button to the left. I did this for as many buttons as were active and disabled all other buttons, which I aligned to a place that wasn't a control. And they were made not visible, too. Also not tab stops. While I was at it, I also identified the label controls and manipulated them, too.

As I clicked a button, part of the underlying code computed which buttons became "legal" in that context. I made the button placement code a subroutine that would traverse all buttons, placing the active ones and displacing the inactive ones. Obviously, activation and deactivation were external to the placement code. The buttons were separately activated based on a context subroutine that decided which buttons were legal at the time. So eventually this narrowed down to two subroutines called during each button-click event. It was a pretty slick little form if I do say so myself.
 
Dear WayneRyan,

Thanks for your question. I use this because in a report I have five fields. I want to display these fields according to the user option. Before displaying the report, I show a form asking the user to check the control names, he want to see in the report.
Thus, if the user selcect only 2 controls out of 5 controls, then I distribure the report vertical space on 2. then align the report but moving these fields using the left properies.

I will be very happy if you can give me a way to do this without this long way. Is it possible at the report view to give the user the option to hide/show report fields?

Thanks
 
Accessor,

There are no *easy* ways to do this. You can see by Doc's dissertation that
as your needs get more complex, the amount of code and effort increases
also. But, it can make things look really nice sometimes. Thanks for the input
Doc.

If you name your controls appropriately, you can save some work by looping
through them in your code, but you still have to implement the logic.

It is definitely "possible" to get user input after the report opens, but for
practical purposes your approach is the proper one.

Wayne
 

Users who are viewing this thread

Back
Top Bottom