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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Text wrapping in grid textbox on certain characters

Status
Not open for further replies.

TomLeMes

MIS
Mar 19, 2004
96
GB
I have a grid class that I'm fairly happy with - it does standard stuff like click sorting, incremental search, that kind of thing. However, when a cell gets focus, and the text in that cell contains one of several particular characters, the text wraps at those characters! As the textbox is only a single line this is a real problem.

For example, I put the following text in a grid cell: "abcedefghijklmnopqrstuvwxyz". While the cell doesn't have focus it looks fine. However, when I click in that cell what I see is: "abcedefghi" - if I drag the mouse down I then see: "j" followed very quickly by "klmnop", then "q" then "rstuvw" then "x" then "y" then "z" - like each text block is on a new line! It's only when I drag downwards that I then get to the end of the text. I can then drag back upwards to get to the beginning of the text. The problem characters seem to be j, q, v, w, x, y and z - if I type in the same string with those characters removed there is no problem! Introducing any one of them causes the line to wrap at that point, effectively they're working like line breaks! Same thing happens with uppercase characters.

And this only happens in some instances of the class! I know this sounds really weird but I promise it is happening! Any ideas? The grids are bound to views of remote SQL2000 database created using SQLEXEC. The column, header and textbox are all subclassed but none of them have any code that would cause this (as far as I can tell). I can post the code for the textbox, column and header classes if that would help.
 
Well this just gets stranger - the behaviour (for the moment) has ceased.

Same thing happened a couple of days ago - the behaviour occurred so I reverted a couple of likely properties/lines of code (including sparse) back to previous settings before the behaviour occured. That seemed to fix the problem so one by one I reinstated the properties/lines of code to see which one was causing the behaviour, but managed to reinstate them all without the behaviour returning!

You're right Mike, the sparse property is currently .T. and was .F. before the behaviour started. But the only noticeable thing that changing it to .F. does now is mess up my row highlighting ;)

I'm stumped and tempted to ignore it for the moment (the problem is gone now), but if it can return once I suspect it'll return again...
 
Well, I've put this issue off for ages now, but it just won't go away!

To recap, if certain characters appear in the text of my grid cells, the text wraps at the point of those certain characters when the cell receives focus! For example, if I put the text "Victoria" in the field, then click it, everything is fine. But if I enter the text "Waterloo", then click it, what I actually see is "W". If I then hold down the left mouse button and drag down, I see "aterloo"! In the past it appeared to be a different set of characters causing this, but now I find Q and W cause it (consistently).

I've said all this before (above), but a new thing I've noticed that might provide a clue: when I double-click the column divider in the header (to autosize it), provided there are no Qs or Ws then it autosizes as usual to the width of the longest string contained. However, if there is a Q or W then it will autosize to the maximum possible width (the remaining width of the grid). It's like the string is too long to fit in the column, even though it clearly isn't! I've tried setting the format to F and T on my grid cell class but this doesn't help.

Any ideas on what could cause this or even what I could try next?
 
Are you in VFP 9? I ask because Q and W are the one-letter abbeviations for new data types in VFP 9. I can't imagine how that could be connected, but it seems like a clue.

Tamar
 
Hi Tamar,

Yes I am using VFP 9. I appreciate your input - I guess I have to consider all possibilities as the 'logical' explanations don't seem to be working here!

One point: all of the controls involved here are my own subclasses - the grid, column, header and textbox. Could anyone suggest which of these is most likely to be the culprit? It would just be helpful to know which one to concentrate my efforts upon. Thanks again,

Tom
 

Tom,

The best way of solving these sort of problems is to try to reproduce the behaviour in the simplest way. Start with a blank form, add your grid class, and then keeping adding more bits, one at a time, until the problem comes back.

If you can get the whole thing down to a simple bit of code, you could post it here so that others can try it.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Thanks Mike,

Sounds advice as usual - I'll give this a go when I get a chance and see what happens! Thanks,

Tom
 
One thing I thought might be causing this problem (of text wrapping within certain grid columns so that only a few characters are visible) was the mapping of SQL Server varchar fields to VFP char fields. I have eliminated this possibility by using
Code:
CURSORSETPROP("MapVarchar",.t.,0)
I can confirm that this successfully sorts out the field mapping but doesn't fix my grid problem.

However one (hopefully significant) thing I have noticed is that if I double-click the column divider on problematic columns they always resize themselves to the maximum width available in the grid (i.e. right over to the right edge of the grid). This is strange in itself, but more interesting is that once I have done this the text no longer wraps and behaves normally. This fixes the problem even if I resize various other columns in my grid in such a way that my problem column autosizes to just a little over its normal width. However, if I manually resize the column to the same width the wrapping continues.

So I was wondering if anyone knew anything about what happens to grids/columns when that autosizing behaviour occurs (when user dblclicks the column divider in the headers). It seems to be a 'native' behaviour but does it have any other effects or set off any events?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top