Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Conditionally moving / aligning form objects
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 10
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01646942
Message ID:
01646960
Views:
96
>I have a pageframe which contains a few dozen checkboxes, grouped together in related 'columns' or areas of the page. Something like the following, but with varying #s of options in a couple different groups.
>
>Option A
>Option B
>Option C
>Option D
>Option E
>Option F
>Option G
>
>Another administrator option allows users to hide selected checkboxes on the pageframe referenced above, by the form's INIT or the object's REFRESH. So Option B, D and F, for example, could be "turned off" or hidden.
>
>Can anyone suggest an elegant, non-brute force way of conditionally setting the TOP of a given object based on the VISIBLE setting of each object? Such that the visible objects are vertically aligned next to each other, without gaps from the non-visible objects.

This is the code I use for those situations:
LOCAL ARRAY laControls(1,2)

LOCAL lnCounter
lnCounter = 0

LOCAL loCheckbox AS Checkbox
FOR EACH loCheckbox IN THIS.Controls
	IF loCheckbox.Class = "Checkbox" ;
			AND loCheckbox.Visible = .T.
		lnCounter = lnCounter + 1
		DIMENSION laControls(lnCounter,2)
		laControls(lnCounter,1) = loCheckbox.Top
		laControls(lnCounter,2) = loCheckbox.Name
	ENDIF
ENDFOR

=ASORT(laControls)

LOCAL lnPosition, lnOffset
lnPosition = 0
lnOffset = 3

LOCAL lnID
FOR lnID = 1 TO lnCounter
	loCheckbox = EVALUATE("THIS." + laControls(lnID,2))
	loCheckbox.Top = lnPosition
	lnPosition = lnPosition + loCheckbox.Height + lnOffset
ENDFOR

RETURN .T.
Christian Isberner
Software Consultant
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform