Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Wrap Text Within Textbox

Status
Not open for further replies.

JRB-Bldr

Programmer
May 17, 2001
3,281
US
If this has been posted, I apologize. Since the Tek-Tips Search utility is not working I'll have to ask the question (possibly again).

Is there a way to get Text to wrap within a Textbox on a Form?

I can easily make the height of the Textbox taller, but I do not believe that, by itself, will cause the LONG text string contained within the Textbox.ControlSource to 'wrap' for display purposes instead of visually appearing truncated on the Right by the narrower width of the Textbox.

Any suggestions?

Thanks,
JRB-Bldr
 

I can easily make the height of the Textbox taller, but I do not believe that, by itself, will cause the LONG text string contained within the Textbox.ControlSource to 'wrap' for display purposes instead of visually appearing truncated on the Right by the narrower width of the Textbox.


Well, the behavior you want is the usual behavior I get in my VFP6 (just checked again to make sure). If the TextBox is narrow and tall, it is what happens - the text just wraps. Do you get something else?

At the same time, I believe that I've read somewhere here that the max length for this exists, like 254 symbols, or so, I don't remeber, and the rest will be truncated. Need to test to be sure, though.

 
Stella - in our VFP7 applications when the ControlSource is a memory variable which is longer than can be displayed in a given textbox, only the left portion (assuming Left alignment) is shown. The user can click into the text box and use the arrow keys to move the cursor right and look at the right-most portion of the string, but otherwise they cannot see it on-screen.

Dave - I will try your suggestion of an EditBox and see how it works.

Thanks,
JRB-Bldr
 
JRB-Bldr,

Dave is right.

The EditBox is the only editable control that supports wordwrap. (Labels, checkboxes, option buttons, command buttons - and, in some version, headers - all support wordwrap, but not in user-editable text.)

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
JRB-Bldr:

Why not display the text in a Tooltip when the user hovers the textbox with the mouse. This is how you would do it:
Code:
&&&& Textbox.MouseEnter()
If !Empty(This.Value) And Vartype(This.Value) = "C"
	nSize = Fontmetric(6,This.FontName,This.FontSize)
	If ((Len(Alltrim(This.Value))*nSize)+nSize) > This.Width
		This.ToolTipText = Alltrim(This.Value)
	Endif
Endif
This will only fire if the value is wider than the textbox width.
Again this is to give you an idea on how to do this, you will have to fine tune

 
Thanks everyone for your suggestions.

I tried Dave's suggestion of using the EditBox and it did the job as needed.

Since the ControlSource for this form object is the value from a Memo field, the value itself has been up to 700 characters long (although typically not nearly that long). The EditBox works well to display (used in ReadOnly mode only) this to the user.

Thanks again,
JRB-Bldr
 
Openion
-------

Stella is right.

The TextBox Default behavior is 'wrap'. I learned this when I was new to VFP. The main difference that I found between TextBox and EditBox is that TextBox does not entertain Carriage Return Line Feed and some other chars, where EditBox has no problem. If you set enough height to host two lines, text will WRAP. It does not wrap in the GridControl even you have enough height to host 2 or more lines, I have to seek pro help to get it working.

In JRB-Bldr situation, since he is using as readonly control, both controls will work fine, but EditBox may be more attractive because of the ScrollBar. In read/write control, it may be more suitable to use TextBox for Char fields and EditBox for Memo fields.


Nasib Kalsi
 

Nasib,

jrbbldr has a memo field, not a character string.
An EditBox is indeed would be more appropriate there than a TextBox. If text in the memo field is long enough, TextBox would not be working so well, even for read-only control.
 
Thanks Stella for pointing out.
That is what happens when one does not read but browse.

I just missed it, because the original question does not mention Memo/Char field. My appologies.


Nasib Kalsi



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top