Normal Topic Position of Text Within a Field (Read 1016 times)
SpencerWulwick
Senior Member
Members
*****
Offline



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Position of Text Within a Field
Jul 9th, 2013 at 4:03pm
Print Post Print Post  
Hmmm -

I never needed to do this before but I need it now and it doesn't look like it's available.

I want to edit some text elements so that the text is positioned in the center of the element.

All I see in designer is to "Left Justify" or "Right Justify" text.  If there's not currently a way to do this, is it possible that it can be added?

Hoping for a highly favorable answer.   Grin
  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged
 
PianoMan
Member
Members
*
Offline


No personal text

Posts: 44
Joined: Oct 13th, 2004
Re: Position of Text Within a Field
Reply #1 - Jul 9th, 2013 at 5:22pm
Print Post Print Post  
Spencer,

You're correct, there is no 'Center' for a text box. However here is a method that simulates it.
Code
Select All
/*  On Form Entry for the form --
    Center text in the 'Last' element.
    Depending on the length of the text box,
    the number '24' will need to be modified
    by trial and error.
*/
Last = @Text((24 - @Len(Last))/2, " ") + Last
 



This code simply adds leading blank spaces to the element. What's cool is that when you leave the form, the blank spaces disappear, i.e. they don't appear in reports, etc.
  
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Position of Text Within a Field
Reply #2 - Jul 9th, 2013 at 5:36pm
Print Post Print Post  
Is this a report or form?

I'd strongly recommend that you use a dynamically updating static text instead of text box. They support centered alignment without further code.

  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
PianoMan
Member
Members
*
Offline


No personal text

Posts: 44
Joined: Oct 13th, 2004
Re: Position of Text Within a Field
Reply #3 - Jul 9th, 2013 at 6:53pm
Print Post Print Post  
Mark - Thanks for the recommendation. The problem with a static text box is that you would still need a database field for entering data. You would end up with two elements.
Why would we want to avoid adding leading spaces?
  
Back to top
IP Logged
 
SpencerWulwick
Senior Member
Members
*****
Offline



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Re: Position of Text Within a Field
Reply #4 - Jul 9th, 2013 at 8:11pm
Print Post Print Post  
OK - First comment - to Mark - It's clear (now) that it is not currently an option in the program, itself.  It is not clear, however, whether it could be done.  I would think that with all the sophisticated programming you do, this would be relatively simple. Assuming it could be done, I would like to suggest/request that it be included.  Do you think that's a possibility?

Second comment to PianoMan - FANTASTIC!!!!! 

Short, sweet and to the point.  Only minor factor is that it appears to be dependent on the width of the letters/numbers used.  But I tried it right away and am THRILLED.  Thank you so much.  In case you're wondering, I have three picture fields (in a row) and a place for "comments" (such as date taken, etc.) below each one.  Now, I LOVE looking at it.

Seriously, thank you so very much.  I am really enjoying and appreciating it.   Smiley



  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged
 
PianoMan
Member
Members
*
Offline


No personal text

Posts: 44
Joined: Oct 13th, 2004
Re: Position of Text Within a Field
Reply #5 - Jul 9th, 2013 at 8:39pm
Print Post Print Post  
Spencer,

You're very welcome! If you use a fixed ( monospaced) font, like Lucida Console or Courier, you'll overcome different letter and number widths.
  
Back to top
IP Logged
 
SpencerWulwick
Senior Member
Members
*****
Offline



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Re: Position of Text Within a Field
Reply #6 - Jul 9th, 2013 at 8:57pm
Print Post Print Post  
I appreciate the suggestion; however, that's uglier than if it's slightly off-center ... so I'll stick with what I've got.  Thanks, again.
  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged